brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 724e038 Raw
45 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// A small condensed version of a problem requiring constant alloca raising in4// Target Region Entries for user injected code, found in an issue in the Flang5// compiler. Certain LLVM IR optimisation passes will perform runtime breaking 6// transformations on allocations not found to be in the entry block, current7// OpenMP dialect lowering of TargetOp's will inject user allocations after8// compiler generated entry code, in a separate block, this test checks that9// a small function which attempts to raise some of these (specifically 10// constant sized) allocations performs its task reasonably in these 11// scenarios. 12 13module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_target_device = true} {14  llvm.func @_QQmain() attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>} {15    %1 = llvm.mlir.constant(1 : i64) : i6416    %2 = llvm.alloca %1 x !llvm.struct<(ptr)> : (i64) -> !llvm.ptr17    %3 = omp.map.info var_ptr(%2 : !llvm.ptr, !llvm.struct<(ptr)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr18    omp.target map_entries(%3 -> %arg0 : !llvm.ptr) {19      %4 = llvm.mlir.constant(1 : i32) : i3220      %5 = llvm.alloca %4 x !llvm.struct<(ptr)> {alignment = 8 : i64} : (i32) -> !llvm.ptr<5>21      %ascast1 = llvm.addrspacecast %5 : !llvm.ptr<5> to !llvm.ptr22      %6 = llvm.mlir.constant(50 : i32) : i3223      %7 = llvm.mlir.constant(1 : i64) : i6424      %8 = llvm.alloca %7 x i32 : (i64) -> !llvm.ptr<5>25      %ascast2 = llvm.addrspacecast %8 : !llvm.ptr<5> to !llvm.ptr26      llvm.store %6, %ascast2 : i32, !llvm.ptr27      %9 = llvm.mlir.undef : !llvm.struct<(ptr)>28      %10 = llvm.insertvalue %ascast2, %9[0] : !llvm.struct<(ptr)> 29      llvm.store %10, %ascast1 : !llvm.struct<(ptr)>, !llvm.ptr30      %88 = llvm.call @_ExternalCall(%arg0, %ascast1) : (!llvm.ptr, !llvm.ptr) -> !llvm.struct<()>31      omp.terminator32    }33    llvm.return34  }35  llvm.func @_ExternalCall(!llvm.ptr, !llvm.ptr) -> !llvm.struct<()>36}37 38// CHECK:      define weak_odr protected amdgpu_kernel void @{{.*}}QQmain_l{{.*}}({{.*}}, {{.*}}) #{{[0-9]+}} {39// CHECK-NEXT: entry:40// CHECK-NEXT:  %[[MOVED_ALLOCA1:.*]] = alloca { ptr }, align 841// CHECK-NEXT:  %[[MOVED_ALLOCA2:.*]] = alloca i32, i64 1, align 442// CHECK-NEXT:  %[[MAP_ARG_ALLOCA:.*]] = alloca ptr, align 843 44// CHECK: user_code.entry:                                  ; preds = %entry45