116 lines · plain
1; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=hipstdpar-select-accelerator-code \2; RUN: %s | FileCheck %s3 4$_ZNK8CallableclEPi = comdat any5$_ZNK8CallableclEPf = comdat any6$_ZNK8Callable6mem_fnEPKi = comdat any7$_ZN8Callable13static_mem_fnEPKi = comdat any8; CHECK-NOT: $_ZNK8Callable37another_mem_fn_which_will_get_removedEPKf9$_ZNK8Callable37another_mem_fn_which_will_get_removedEPKf = comdat any10; CHECK-NOT: $_ZN8Callable44another_static_mem_fn_which_will_get_removedEPKf11$_ZN8Callable44another_static_mem_fn_which_will_get_removedEPKf = comdat any12 13%struct.Callable = type { [64 x i8] }14 15; CHECK-NOT: @should_be_removed16@llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr @should_be_removed], section "llvm.metadata"17 18define void @should_be_removed(ptr %p) {19 ret void20}21 22declare void @llvm.trap()23 24; CHECK: define {{.*}} @called_via_chain25define void @called_via_chain(ptr %p) {26 entry:27 %tobool.not = icmp eq ptr %p, null28 br i1 %tobool.not, label %if.then, label %if.end29 30 if.then:31 tail call void @llvm.trap()32 unreachable33 34 if.end:35 ret void36}37 38; CHECK: define {{.*}} @directly_called39define void @directly_called(ptr %p) {40 tail call void @called_via_chain(ptr %p)41 ret void42}43 44; CHECK: define {{.*}} amdgpu_kernel {{.*}} @accelerator_execution_root45define hidden amdgpu_kernel void @accelerator_execution_root(ptr %p) {46 tail call void @directly_called(ptr %p)47 ret void48}49 50; CHECK-NOT: @defined_elsewhere_should_be_removed51declare void @defined_elsewhere_should_be_removed(ptr)52 53; CHECK: declare {{.*}} @defined_elsewhere_directly_called54declare void @defined_elsewhere_directly_called(ptr)55 56; CHECK: define {{.*}} amdgpu_kernel {{.*}} @another_accelerator_execution_root57define hidden amdgpu_kernel void @another_accelerator_execution_root(ptr %p) {58 tail call void @defined_elsewhere_directly_called(ptr %p)59 ret void60}61 62; Also test passing a callable object (functor / lambda) to a kernel, which is63; the common pattern for customising algorithms.64 65; CHECK: define {{.*}} amdgpu_kernel {{.*}} @_Z22accelerator_execution_root_taking_callablePi8Callable66define hidden amdgpu_kernel void @_Z22accelerator_execution_root_taking_callablePi8Callable(ptr noundef %p, ptr addrspace(4) nocapture readonly byref(%struct.Callable) align 8 %callable) {67 %callable_in_generic = addrspacecast ptr addrspace(4) %callable to ptr68 call void @_ZNK8CallableclEPi(ptr noundef nonnull align 1 dereferenceable(64) %callable_in_generic, ptr noundef %p)69 70 ret void71}72 73; CHECK: define {{.*}} @_ZNK8CallableclEPi74define linkonce_odr dso_local void @_ZNK8CallableclEPi(ptr noundef nonnull align 1 dereferenceable(64) %this, ptr noundef %p) {75 call void @_ZNK8Callable6mem_fnEPKi(ptr noundef nonnull align 1 dereferenceable(1) %this, ptr noundef %p)76 77 ret void78}79 80; CHECK: define {{.*}} @_ZNK8Callable6mem_fnEPKi81define linkonce_odr dso_local void @_ZNK8Callable6mem_fnEPKi(ptr noundef nonnull align 1 dereferenceable(1) %this, ptr noundef %p) {82 call void @_ZN8Callable13static_mem_fnEPKi(ptr noundef %p)83 84 ret void85}86 87; CHECK: define {{.*}} @_ZN8Callable13static_mem_fnEPKi88define linkonce_odr dso_local void @_ZN8Callable13static_mem_fnEPKi(ptr noundef %p) {89 ret void90}91 92; CHECK-NOT: define {{.*}} @_Z26non_kernel_taking_callablePf8Callable93define dso_local void @_Z26non_kernel_taking_callablePf8Callable(ptr noundef %p, ptr noundef byval(%struct.Callable) align 8 %callable) {94 call void @_ZNK8CallableclEPf(ptr noundef nonnull align 1 dereferenceable(64) %callable, ptr noundef %p)95 96 ret void97}98 99; CHECK-NOT: define {{.*}} @_ZNK8CallableclEPf100define linkonce_odr dso_local void @_ZNK8CallableclEPf(ptr noundef nonnull align 1 dereferenceable(64) %this, ptr noundef %p) {101 call void @_ZNK8Callable37another_mem_fn_which_will_get_removedEPKf(ptr noundef nonnull align 1 dereferenceable(64) %this, ptr noundef %p)102 103 ret void104}105 106; CHECK-NOT: @_ZNK8Callable37another_mem_fn_which_will_get_removedEPKf107define linkonce_odr dso_local void @_ZNK8Callable37another_mem_fn_which_will_get_removedEPKf(ptr noundef nonnull align 1 dereferenceable(64) %this, ptr noundef %p) {108 call void @_ZN8Callable44another_static_mem_fn_which_will_get_removedEPKf(ptr noundef %p)109 110 ret void111}112 113; CHECK-NOT: @_ZN8Callable44another_static_mem_fn_which_will_get_removedEPKf114define linkonce_odr dso_local void @_ZN8Callable44another_static_mem_fn_which_will_get_removedEPKf(ptr noundef %p) {115 ret void116}