brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · a61c553 Raw
81 lines · plain
1// Make sure that invoking blocks in static functions with the same name in2// different modules are linked together.3 4// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -fno-ident -DKERNEL_NAME=test_kernel_first -DTYPE=float -DCONST=256.0f -emit-llvm-bc -o %t.0.bc %s5// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -fno-ident -DKERNEL_NAME=test_kernel_second -DTYPE=int -DCONST=128.0f -emit-llvm-bc -o %t.1.bc %s6 7// Make sure nothing strange happens with the linkage choices.8// RUN: opt -passes=globalopt -o %t.opt.0.bc %t.0.bc9// RUN: opt -passes=globalopt -o %t.opt.1.bc %t.1.bc10 11// Check the result of linking12// RUN: llvm-link -S %t.opt.0.bc %t.opt.1.bc -o - | FileCheck %s13 14// Make sure that a block invoke used with the same name works in multiple15// translation units16 17// CHECK: @llvm.used = appending addrspace(1) global [4 x ptr] [ptr @__static_invoker_block_invoke_kernel, ptr addrspacecast (ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle to ptr), ptr @__static_invoker_block_invoke_kernel.2, ptr addrspacecast (ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle.3 to ptr)], section "llvm.metadata"18 19 20// CHECK: @__static_invoker_block_invoke_kernel.runtime.handle = internal addrspace(1) externally_initialized constant %block.runtime.handle.t zeroinitializer, section ".amdgpu.kernel.runtime.handle"21// CHECK: @__static_invoker_block_invoke_kernel.runtime.handle.3 = internal addrspace(1) externally_initialized constant %block.runtime.handle.t zeroinitializer, section ".amdgpu.kernel.runtime.handle"22 23// CHECK: define internal amdgpu_kernel void @__static_invoker_block_invoke_kernel(<{ i32, i32, ptr, ptr addrspace(1), ptr addrspace(1) }> %0) #{{[0-9]+}} !associated ![[ASSOC_FIRST_MD:[0-9]+]]24 25 26// CHECK-LABEL: define internal void @__static_invoker_block_invoke(ptr noundef %.block_descriptor)27// CHECK: call float @llvm.fmuladd.f3228 29 30// CHECK-LABEL: define dso_local amdgpu_kernel void @test_kernel_first(31 32 33// CHECK-LABEL: define internal fastcc void @static_invoker(ptr addrspace(1) noundef %outptr, ptr addrspace(1) noundef %argptr)34// CHECK:  call i32 @__enqueue_kernel_basic(ptr addrspace(1) %{{[0-9]+}}, i32 %{{[0-9]+}}, ptr addrspace(5) %tmp, ptr addrspacecast (ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle to ptr), ptr %{{.+}})35 36// CHECK: declare i32 @__enqueue_kernel_basic(ptr addrspace(1), i32, ptr addrspace(5), ptr, ptr) local_unnamed_addr37 38 39// CHECK: define internal amdgpu_kernel void @__static_invoker_block_invoke_kernel.2(<{ i32, i32, ptr, ptr addrspace(1), ptr addrspace(1) }> %0) #{{[0-9]+}} !associated ![[ASSOC_SECOND_MD:[0-9]+]]40// CHECK: call void @__static_invoker_block_invoke.4(ptr %41 42 43// CHECK-LABEL: define internal void @__static_invoker_block_invoke.4(ptr noundef %.block_descriptor)44// CHECK: mul nsw i3245// CHECK: sitofp46// CHECK: fadd47// CHECK: fptosi48 49// CHECK-LABEL: define dso_local amdgpu_kernel void @test_kernel_second(ptr addrspace(1) noundef align 4 %outptr, ptr addrspace(1) noundef align 4 %argptr, ptr addrspace(1) noundef align 4 %difference)50 51// CHECK-LABEL: define internal fastcc void @static_invoker.5(ptr addrspace(1) noundef %outptr, ptr addrspace(1) noundef %argptr) unnamed_addr #{{[0-9]+}} {52// CHECK: call i32 @__enqueue_kernel_basic(ptr addrspace(1) %{{[0-9]+}}, i32 %{{[0-9]+}}, ptr addrspace(5) %tmp, ptr addrspacecast (ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle.3 to ptr), ptr %{{.+}})53 54 55typedef struct {int a;} ndrange_t;56 57static void static_invoker(global TYPE* outptr, global TYPE* argptr) {58  queue_t default_queue;59  unsigned flags = 0;60  ndrange_t ndrange;61 62  enqueue_kernel(default_queue, flags, ndrange,63  ^(void) {64  global TYPE* f = argptr;65  outptr[0] = f[1] * f[2] + CONST;66  });67}68 69kernel void KERNEL_NAME(global TYPE *outptr, global TYPE *argptr, global TYPE *difference) {70  queue_t default_queue;71  unsigned flags = 0;72  ndrange_t ndrange;73 74  static_invoker(outptr, argptr);75 76  *difference = CONST;77}78 79// CHECK: ![[ASSOC_FIRST_MD]] = !{ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle}80// CHECK: ![[ASSOC_SECOND_MD]] = !{ptr addrspace(1) @__static_invoker_block_invoke_kernel.runtime.handle.3}81