blob: f73a30a5e664db00b5746c1abbb056d21466af28 [file] [log] [blame] [edit]
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
// Check converting code where there are operations other than omp.taskloop
// inside of omp.taskloop.context.
// The following is a common pattern generated by flang when accessing
// mutable boxes (e.g. ALLOCATABLE) inside of a taskloop
omp.private {type = private} @_QFtest_taskloopEi_private_i32 : i32
llvm.func @_QPtest_taskloop(%arg0: !llvm.ptr) {
%0 = llvm.mlir.constant(48 : i32) : i32
%1 = llvm.mlir.constant(1 : i32) : i32
%2 = llvm.mlir.constant(100 : i32) : i32
%3 = llvm.mlir.constant(1 : i64) : i64
%4 = llvm.alloca %3 x i32 : (i64) -> !llvm.ptr
omp.taskloop.context private(@_QFtest_taskloopEi_private_i32 %4 -> %arg1 : !llvm.ptr) {
// test where this alloca ends up
%5 = llvm.alloca %1 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
omp.taskloop {
omp.loop_nest (%arg2) : i32 = (%1) to (%2) inclusive step (%1) {
llvm.store %arg2, %arg1 : i32, !llvm.ptr
"llvm.intr.memcpy"(%5, %arg0, %0) <{arg_attrs = [{llvm.align = 8 : i64}, {llvm.align = 8 : i64}, {}], isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
%6 = llvm.getelementptr %5[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>
%7 = llvm.load %6 : !llvm.ptr -> !llvm.ptr
llvm.call @_QPdo_something(%7) {fastmathFlags = #llvm.fastmath<contract>} : (!llvm.ptr) -> ()
omp.yield
}
}
omp.terminator
}
llvm.return
}
llvm.func @_QPdo_something(!llvm.ptr) attributes {sym_visibility = "private"}
// Outlined task function:
// CHECK-LABEL: define internal void @_QPtest_taskloop..omp_par(
// CHECK: taskloop.alloca:
// ...
// CHECK: br label %[[VAL_31:taskloop.body]]
// CHECK: taskloop.body: ; preds = %[[VAL_32:.*]]
// CHECK-NEXT: br label %[[VAL_33:omp.taskloop.context.region]]
// CHECK: omp.taskloop.context.region: ; preds = %[[VAL_31]]
// This will be folded into the entry block by later optimization passes:
// CHECK-NEXT: %[[VAL_34:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
// CHECK-NEXT: br label %[[VAL_35:omp.taskloop.region]]