Skip to content

Commit 9688aa2

Browse files
committed
[flang][OpenMP] Allow saving first block of an OMP region for allocas
Problem: -------- Consider the following example: ```fortran program test real :: x(1) integer :: i !$omp parallel do reduction(+:x) do i = 1,1 x = 1 end do !$omp end parallel do end program ``` The HLFIR+OMP IR for this example looks like this: ```mlir func.func @_QQmain() { ... omp.parallel { %5 = fir.embox %4#0(%3) : (!fir.ref<!fir.array<1xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<1xf32>> %6 = fir.alloca !fir.box<!fir.array<1xf32>> ... omp.wsloop private(@_QFEi_private_ref_i32 %1#0 -> %arg0 : !fir.ref<i32>) reduction(byref @add_reduction_byref_box_1xf32 %6 -> %arg1 : !fir.ref<!fir.box<!fir.array<1xf32>>>) { omp.loop_nest (%arg2) : i32 = (%c1_i32) to (%c1_i32_0) inclusive step (%c1_i32_1) { ... omp.yield } } omp.terminator } return } ``` The problem addressed by this PR is related to: the `alloca` in the `omp.parallel` region + the related `reduction` clause on the `omp.wsloop` op. When we try translate the reduction from MLIR to LLVM, we have to choose an `alloca` insertion point. This happens in `convertOmpWsloop` where at entry to that function, this is what the LLVM module looks like: ```llvm define void @_QQmain() { %tid.addr = alloca i32, align 4 ... entry: %omp_global_thread_num = call i32 @__kmpc_global_thread_num(ptr @1) br label %omp.par.entry omp.par.entry: %tid.addr.local = alloca i32, align 4 ... br label %omp.par.region omp.par.region: br label %omp.par.region1 omp.par.region1: ... %5 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8 ``` Possible solution: ------------------ Now, when we choose an `alloca` insertion point for the reduction, this is the chosen block `omp.par.entry` (without the changes in this PR). The problem is that the allocation needed for the reduction needs to reference the `%5` SSA value. This results in inserting allocations in `omp.par.entry` that reference allocations in a later block `omp.par.region1` which causes the `Instruction does not dominate all uses!` error. The solution proposed by this PR is to allow `convertOmpOpRegions` to optionally save the first block of the OpenMP region being converted as an alloca block. This means that, for the above example, the allocation point chosen for the reduction will be in the `omp.par.region1` block. For now, this new optional argument is enbled only for `parallel` and `target` ops.
1 parent 737d6ca commit 9688aa2

File tree

10 files changed

+122
-97
lines changed

10 files changed

+122
-97
lines changed

flang/test/Integration/OpenMP/atomic-capture-complex.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
!CHECK: %[[VAL_1:.*]] = alloca { float, float }, i64 1, align 8
1414
!CHECK: %[[ORIG_VAL:.*]] = alloca { float, float }, i64 1, align 8
1515
!CHECK: store { float, float } { float 2.000000e+00, float 2.000000e+00 }, ptr %[[ORIG_VAL]], align 4
16-
!CHECK: br label %entry
16+
!CHECK: br label %[[ENTRY:.*]]
1717

18-
!CHECK: entry:
18+
!CHECK: [[ENTRY]]:
1919
!CHECK: %[[ATOMIC_TEMP_LOAD:.*]] = alloca { float, float }, align 8
2020
!CHECK: call void @__atomic_load(i64 8, ptr %[[ORIG_VAL]], ptr %[[ATOMIC_TEMP_LOAD]], i32 0)
2121
!CHECK: %[[PHI_NODE_ENTRY_1:.*]] = load { float, float }, ptr %[[ATOMIC_TEMP_LOAD]], align 8
2222
!CHECK: br label %.atomic.cont
2323

2424
!CHECK: .atomic.cont
25-
!CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %entry ], [ %{{.*}}, %.atomic.cont ]
25+
!CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %[[ENTRY]] ], [ %{{.*}}, %.atomic.cont ]
2626
!CHECK: %[[VAL_5:.*]] = extractvalue { float, float } %[[VAL_4]], 0
2727
!CHECK: %[[VAL_6:.*]] = extractvalue { float, float } %[[VAL_4]], 1
2828
!CHECK: %[[VAL_7:.*]] = fadd contract float %[[VAL_5]], 1.000000e+00

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -345,31 +345,37 @@ findAllocaInsertPoint(llvm::IRBuilderBase &builder,
345345
allocaInsertPoint = frame.allocaInsertPoint;
346346
return WalkResult::interrupt();
347347
});
348-
if (walkResult.wasInterrupted())
349-
return allocaInsertPoint;
350348

351349
// Otherwise, insert to the entry block of the surrounding function.
352-
// If the current IRBuilder InsertPoint is the function's entry, it cannot
353-
// also be used for alloca insertion which would result in insertion order
354-
// confusion. Create a new BasicBlock for the Builder and use the entry block
355-
// for the allocs.
350+
if (!walkResult.wasInterrupted()) {
351+
llvm::BasicBlock &funcEntryBlock =
352+
builder.GetInsertBlock()->getParent()->getEntryBlock();
353+
allocaInsertPoint = llvm::OpenMPIRBuilder::InsertPointTy(
354+
&funcEntryBlock, funcEntryBlock.getFirstInsertionPt());
355+
}
356+
357+
// If the current IRBuilder insertion block is the same as the alloca
358+
// insertion block, it cannot also be used for alloca insertion which would
359+
// result in insertion order confusion. Create a new BasicBlock for the
360+
// Builder and use the entry block for the allocs.
361+
//
356362
// TODO: Create a dedicated alloca BasicBlock at function creation such that
357363
// we do not need to move the current InertPoint here.
358-
if (builder.GetInsertBlock() ==
359-
&builder.GetInsertBlock()->getParent()->getEntryBlock()) {
364+
if (builder.GetInsertBlock() == allocaInsertPoint.getBlock()) {
360365
assert(builder.GetInsertPoint() == builder.GetInsertBlock()->end() &&
361366
"Assuming end of basic block");
362-
llvm::BasicBlock *entryBB = llvm::BasicBlock::Create(
363-
builder.getContext(), "entry", builder.GetInsertBlock()->getParent(),
364-
builder.GetInsertBlock()->getNextNode());
365-
builder.CreateBr(entryBB);
366-
builder.SetInsertPoint(entryBB);
367+
auto *insertCont = splitBB(
368+
llvm::OpenMPIRBuilder::InsertPointTy(
369+
allocaInsertPoint.getBlock(), allocaInsertPoint.getBlock()->end()),
370+
true, "insert.cont");
371+
builder.SetInsertPoint(insertCont, insertCont->end());
367372
}
368373

369-
llvm::BasicBlock &funcEntryBlock =
370-
builder.GetInsertBlock()->getParent()->getEntryBlock();
371374
return llvm::OpenMPIRBuilder::InsertPointTy(
372-
&funcEntryBlock, funcEntryBlock.getFirstInsertionPt());
375+
allocaInsertPoint.getBlock(),
376+
allocaInsertPoint.getPoint() != allocaInsertPoint.getBlock()->end()
377+
? allocaInsertPoint.getPoint()
378+
: allocaInsertPoint.getBlock()->getFirstInsertionPt());
373379
}
374380

375381
/// Converts the given region that appears within an OpenMP dialect operation to
@@ -380,7 +386,8 @@ findAllocaInsertPoint(llvm::IRBuilderBase &builder,
380386
static llvm::Expected<llvm::BasicBlock *> convertOmpOpRegions(
381387
Region &region, StringRef blockName, llvm::IRBuilderBase &builder,
382388
LLVM::ModuleTranslation &moduleTranslation,
383-
SmallVectorImpl<llvm::PHINode *> *continuationBlockPHIs = nullptr) {
389+
SmallVectorImpl<llvm::PHINode *> *continuationBlockPHIs = nullptr,
390+
bool saveFirstBlockForAlloca = false) {
384391
llvm::BasicBlock *continuationBlock =
385392
splitBB(builder, true, "omp.region.cont");
386393
llvm::BasicBlock *sourceBlock = builder.GetInsertBlock();
@@ -441,6 +448,14 @@ static llvm::Expected<llvm::BasicBlock *> convertOmpOpRegions(
441448
// Convert blocks one by one in topological order to ensure
442449
// defs are converted before uses.
443450
SetVector<Block *> blocks = getBlocksSortedByDominance(region);
451+
llvm::BasicBlock *firstLLVMBB = moduleTranslation.lookupBlock(blocks.front());
452+
std::optional<LLVM::ModuleTranslation::SaveStack<OpenMPAllocaStackFrame>>
453+
frame;
454+
455+
if (saveFirstBlockForAlloca)
456+
frame.emplace(moduleTranslation, llvm::OpenMPIRBuilder::InsertPointTy(
457+
firstLLVMBB, firstLLVMBB->end()));
458+
444459
for (Block *bb : blocks) {
445460
llvm::BasicBlock *llvmBB = moduleTranslation.lookupBlock(bb);
446461
// Retarget the branch of the entry block to the entry block of the
@@ -2093,15 +2108,11 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
20932108
LLVM::ModuleTranslation::SaveStack<OpenMPVarMappingStackFrame> mappingGuard(
20942109
moduleTranslation, reductionVariableMap);
20952110

2096-
// Save the alloca insertion point on ModuleTranslation stack for use in
2097-
// nested regions.
2098-
LLVM::ModuleTranslation::SaveStack<OpenMPAllocaStackFrame> frame(
2099-
moduleTranslation, allocaIP);
2100-
21012111
// ParallelOp has only one region associated with it.
21022112
builder.restoreIP(codeGenIP);
21032113
llvm::Expected<llvm::BasicBlock *> regionBlock = convertOmpOpRegions(
2104-
opInst.getRegion(), "omp.par.region", builder, moduleTranslation);
2114+
opInst.getRegion(), "omp.par.region", builder, moduleTranslation,
2115+
/*continuationBlockPHIs=*/nullptr, /*saveFirstBlockForAlloca=*/true);
21052116
if (!regionBlock)
21062117
return regionBlock.takeError();
21072118

@@ -2186,6 +2197,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
21862197

21872198
llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
21882199
findAllocaInsertPoint(builder, moduleTranslation);
2200+
21892201
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
21902202

21912203
llvm::OpenMPIRBuilder::InsertPointOrErrorTy afterIP =
@@ -4022,7 +4034,8 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
40224034

40234035
builder.restoreIP(codeGenIP);
40244036
llvm::Expected<llvm::BasicBlock *> exitBlock = convertOmpOpRegions(
4025-
targetRegion, "omp.target", builder, moduleTranslation);
4037+
targetRegion, "omp.target", builder, moduleTranslation,
4038+
/*continuationBlockPHIs=*/nullptr, /*saveFirstBlockForAlloca=*/true);
40264039

40274040
if (!exitBlock)
40284041
return exitBlock.takeError();

mlir/test/Target/LLVMIR/omptarget-byref-bycopy-generation-host.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-a
2626
// CHECK: define void @_QQmain() {
2727
// CHECK: %[[BYCOPY_ALLOCA:.*]] = alloca ptr, align 8
2828

29-
// CHECK: entry: ; preds = %0
29+
// CHECK: {{.*}}: ; preds = %0
3030
// CHECK: %[[LOAD_VAL:.*]] = load i32, ptr @_QFEi, align 4
3131
// CHECK: store i32 %[[LOAD_VAL]], ptr %[[BYCOPY_ALLOCA]], align 4
3232
// CHECK: %[[BYCOPY_LOAD:.*]] = load ptr, ptr %[[BYCOPY_ALLOCA]], align 8

mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ llvm.func @_QPopenmp_target_data() {
2020
// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
2121
// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
2222
// CHECK: br label %[[VAL_4:.*]]
23-
// CHECK: entry: ; preds = %[[VAL_5:.*]]
23+
// CHECK: [[VAL_4]]: ; preds = %[[VAL_5:.*]]
2424
// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
2525
// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
2626
// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
@@ -65,7 +65,7 @@ llvm.func @_QPopenmp_target_data_region(%0 : !llvm.ptr) {
6565
// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
6666
// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
6767
// CHECK: br label %[[VAL_3:.*]]
68-
// CHECK: entry: ; preds = %[[VAL_4:.*]]
68+
// CHECK: [[VAL_3]]: ; preds = %[[VAL_4:.*]]
6969
// CHECK: %[[ARR_OFFSET:.*]] = getelementptr inbounds [1024 x i32], ptr %[[ARR_DATA:.*]], i64 0, i64 0
7070
// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
7171
// CHECK: store ptr %[[ARR_DATA]], ptr %[[VAL_5]], align 8
@@ -151,7 +151,7 @@ llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr, %3 : !llvm.ptr) {
151151
// CHECK: %[[VAL_9:.*]] = icmp slt i32 %[[VAL_8]], 10
152152
// CHECK: %[[VAL_10:.*]] = load i32, ptr %[[VAL_6]], align 4
153153
// CHECK: br label %[[VAL_11:.*]]
154-
// CHECK: entry: ; preds = %[[VAL_12:.*]]
154+
// CHECK: [[VAL_11]]: ; preds = %[[VAL_12:.*]]
155155
// CHECK: br i1 %[[VAL_9]], label %[[VAL_13:.*]], label %[[VAL_14:.*]]
156156
// CHECK: omp_if.then: ; preds = %[[VAL_11]]
157157
// CHECK: %[[ARR_OFFSET1:.*]] = getelementptr inbounds [1024 x i32], ptr %[[VAL_16:.*]], i64 0, i64 0
@@ -228,7 +228,7 @@ llvm.func @_QPopenmp_target_use_dev_ptr() {
228228
// CHECK: %[[VAL_3:.*]] = alloca ptr, align 8
229229
// CHECK: %[[VAL_4:.*]] = alloca ptr, i64 1, align 8
230230
// CHECK: br label %[[VAL_5:.*]]
231-
// CHECK: entry: ; preds = %[[VAL_6:.*]]
231+
// CHECK: [[VAL_5]]: ; preds = %[[VAL_6:.*]]
232232
// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
233233
// CHECK: store ptr %[[VAL_4]], ptr %[[VAL_7]], align 8
234234
// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
@@ -271,7 +271,7 @@ llvm.func @_QPopenmp_target_use_dev_addr() {
271271
// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
272272
// CHECK: %[[VAL_3:.*]] = alloca ptr, i64 1, align 8
273273
// CHECK: br label %[[VAL_4:.*]]
274-
// CHECK: entry: ; preds = %[[VAL_5:.*]]
274+
// CHECK: [[VAL_4]]: ; preds = %[[VAL_5:.*]]
275275
// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
276276
// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
277277
// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
@@ -312,7 +312,7 @@ llvm.func @_QPopenmp_target_use_dev_addr_no_ptr() {
312312
// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
313313
// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
314314
// CHECK: br label %[[VAL_4:.*]]
315-
// CHECK: entry: ; preds = %[[VAL_5:.*]]
315+
// CHECK: [[VAL_4]]: ; preds = %[[VAL_5:.*]]
316316
// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
317317
// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
318318
// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
@@ -359,7 +359,7 @@ llvm.func @_QPopenmp_target_use_dev_addr_nomap() {
359359
// CHECK: %[[VAL_3:.*]] = alloca ptr, i64 1, align 8
360360
// CHECK: %[[VAL_4:.*]] = alloca ptr, i64 1, align 8
361361
// CHECK: br label %[[VAL_5:.*]]
362-
// CHECK: entry: ; preds = %[[VAL_6:.*]]
362+
// CHECK: [[VAL_5]]: ; preds = %[[VAL_6:.*]]
363363
// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_0]], i32 0, i32 0
364364
// CHECK: store ptr %[[VAL_4]], ptr %[[VAL_7]], align 8
365365
// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_1]], i32 0, i32 0
@@ -418,7 +418,7 @@ llvm.func @_QPopenmp_target_use_dev_both() {
418418
// CHECK: %[[VAL_4:.*]] = alloca ptr, i64 1, align 8
419419
// CHECK: %[[VAL_5:.*]] = alloca ptr, i64 1, align 8
420420
// CHECK: br label %[[VAL_6:.*]]
421-
// CHECK: entry: ; preds = %[[VAL_7:.*]]
421+
// CHECK: [[VAL_6]]: ; preds = %[[VAL_7:.*]]
422422
// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_0]], i32 0, i32 0
423423
// CHECK: store ptr %[[VAL_4]], ptr %[[VAL_8]], align 8
424424
// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_1]], i32 0, i32 0

mlir/test/Target/LLVMIR/omptarget-parallel-llvm.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memo
5454
// CHECK: define weak_odr protected amdgpu_kernel void @[[FUNC0:.*]](
5555
// CHECK-SAME: ptr %[[TMP:.*]], ptr %[[TMP0:.*]]) {
5656
// CHECK: %[[TMP1:.*]] = alloca [1 x ptr], align 8, addrspace(5)
57-
// CHECK: %[[TMP2:.*]] = addrspacecast ptr addrspace(5) %[[TMP1]] to ptr
5857
// CHECK: %[[STRUCTARG:.*]] = alloca { ptr }, align 8, addrspace(5)
59-
// CHECK: %[[STRUCTARG_ASCAST:.*]] = addrspacecast ptr addrspace(5) %[[STRUCTARG]] to ptr
6058
// CHECK: %[[TMP3:.*]] = alloca ptr, align 8, addrspace(5)
6159
// CHECK: %[[TMP4:.*]] = addrspacecast ptr addrspace(5) %[[TMP3]] to ptr
6260
// CHECK: store ptr %[[TMP0]], ptr %[[TMP4]], align 8
6361
// CHECK: %[[TMP5:.*]] = call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @{{.*}} to ptr), ptr %[[TMP]])
6462
// CHECK: %[[EXEC_USER_CODE:.*]] = icmp eq i32 %[[TMP5]], -1
6563
// CHECK: br i1 %[[EXEC_USER_CODE]], label %[[USER_CODE_ENTRY:.*]], label %[[WORKER_EXIT:.*]]
6664
// CHECK: %[[TMP6:.*]] = load ptr, ptr %[[TMP4]], align 8
65+
// CHECK: %[[TMP2:.*]] = addrspacecast ptr addrspace(5) %[[TMP1]] to ptr
66+
// CHECK: %[[STRUCTARG_ASCAST:.*]] = addrspacecast ptr addrspace(5) %[[STRUCTARG]] to ptr
6767
// CHECK: %[[OMP_GLOBAL_THREAD_NUM:.*]] = call i32 @__kmpc_global_thread_num(ptr addrspacecast (ptr addrspace(1) @[[GLOB1:[0-9]+]] to ptr))
6868
// CHECK: %[[GEP_:.*]] = getelementptr { ptr }, ptr addrspace(5) %[[STRUCTARG]], i32 0, i32 0
6969
// CHECK: store ptr %[[TMP6]], ptr addrspace(5) %[[GEP_]], align 8

mlir/test/Target/LLVMIR/openmp-llvm.mlir

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,16 +1415,16 @@ llvm.func @omp_atomic_update(%x:!llvm.ptr, %expr: i32, %xbool: !llvm.ptr, %exprb
14151415
//CHECK: {{.*}} = alloca { float, float }, i64 1, align 8
14161416
//CHECK: %[[ORIG_VAL:.*]] = alloca { float, float }, i64 1, align 8
14171417

1418-
//CHECK: br label %entry
1418+
//CHECK: br label %[[ENTRY:.*]]
14191419

1420-
//CHECK: entry:
1420+
//CHECK: [[ENTRY]]:
14211421
//CHECK: %[[ATOMIC_TEMP_LOAD:.*]] = alloca { float, float }, align 8
14221422
//CHECK: call void @__atomic_load(i64 8, ptr %[[ORIG_VAL]], ptr %[[ATOMIC_TEMP_LOAD]], i32 0)
14231423
//CHECK: %[[PHI_NODE_ENTRY_1:.*]] = load { float, float }, ptr %[[ATOMIC_TEMP_LOAD]], align 8
14241424
//CHECK: br label %.atomic.cont
14251425

14261426
//CHECK: .atomic.cont
1427-
//CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %entry ], [ %{{.*}}, %.atomic.cont ]
1427+
//CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %{{.*}} ], [ %{{.*}}, %.atomic.cont ]
14281428
//CHECK: %[[VAL_5:.*]] = extractvalue { float, float } %[[VAL_4]], 0
14291429
//CHECK: %[[VAL_6:.*]] = extractvalue { float, float } %[[VAL_4]], 1
14301430
//CHECK: %[[VAL_7:.*]] = fadd contract float %[[VAL_5]], 1.000000e+00
@@ -1467,16 +1467,16 @@ llvm.func @_QPomp_atomic_update_complex() {
14671467
//CHECK: %[[VAL_1:.*]] = alloca { float, float }, i64 1, align 8
14681468
//CHECK: %[[ORIG_VAL:.*]] = alloca { float, float }, i64 1, align 8
14691469
//CHECK: store { float, float } { float 2.000000e+00, float 2.000000e+00 }, ptr %[[ORIG_VAL]], align 4
1470-
//CHECK: br label %entry
1470+
//CHECK: br label %[[ENTRY:.*]]
14711471

1472-
//CHECK: entry: ; preds = %0
1472+
//CHECK: [[ENTRY]]: ; preds = %0
14731473
//CHECK: %[[ATOMIC_TEMP_LOAD:.*]] = alloca { float, float }, align 8
14741474
//CHECK: call void @__atomic_load(i64 8, ptr %[[ORIG_VAL]], ptr %[[ATOMIC_TEMP_LOAD]], i32 0)
14751475
//CHECK: %[[PHI_NODE_ENTRY_1:.*]] = load { float, float }, ptr %[[ATOMIC_TEMP_LOAD]], align 8
14761476
//CHECK: br label %.atomic.cont
14771477

14781478
//CHECK: .atomic.cont
1479-
//CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %entry ], [ %{{.*}}, %.atomic.cont ]
1479+
//CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %{{.*}} ], [ %{{.*}}, %.atomic.cont ]
14801480
//CHECK: %[[VAL_5:.*]] = extractvalue { float, float } %[[VAL_4]], 0
14811481
//CHECK: %[[VAL_6:.*]] = extractvalue { float, float } %[[VAL_4]], 1
14821482
//CHECK: %[[VAL_7:.*]] = fadd contract float %[[VAL_5]], 1.000000e+00
@@ -1613,7 +1613,7 @@ llvm.func @omp_atomic_update_intrinsic(%x:!llvm.ptr, %expr: i32) {
16131613
// CHECK-LABEL: @atomic_update_cmpxchg
16141614
// CHECK-SAME: (ptr %[[X:.*]], ptr %[[EXPR:.*]]) {
16151615
// CHECK: %[[AT_LOAD_VAL:.*]] = load atomic i32, ptr %[[X]] monotonic, align 4
1616-
// CHECK: %[[LOAD_VAL_PHI:.*]] = phi i32 [ %[[AT_LOAD_VAL]], %entry ], [ %[[LOAD_VAL:.*]], %.atomic.cont ]
1616+
// CHECK: %[[LOAD_VAL_PHI:.*]] = phi i32 [ %[[AT_LOAD_VAL]], %{{.*}} ], [ %[[LOAD_VAL:.*]], %.atomic.cont ]
16171617
// CHECK: %[[VAL_SUCCESS:.*]] = cmpxchg ptr %[[X]], i32 %[[LOAD_VAL_PHI]], i32 %{{.*}} monotonic monotonic, align 4
16181618
// CHECK: %[[LOAD_VAL]] = extractvalue { i32, i1 } %[[VAL_SUCCESS]], 0
16191619
// CHECK: br i1 %{{.*}}, label %.atomic.exit, label %.atomic.cont
@@ -2216,8 +2216,8 @@ llvm.func @omp_sections_empty() -> () {
22162216
omp.sections {
22172217
omp.terminator
22182218
}
2219-
// CHECK-NEXT: br label %entry
2220-
// CHECK: entry:
2219+
// CHECK-NEXT: br label %[[ENTRY:.*]]
2220+
// CHECK: [[ENTRY]]:
22212221
// CHECK-NEXT: ret void
22222222
llvm.return
22232223
}
@@ -3093,7 +3093,7 @@ llvm.func @omp_task_final(%boolexpr: i1) {
30933093
// CHECK: br label %[[entry:[^,]+]]
30943094
// CHECK: [[entry]]:
30953095
// CHECK: br label %[[codeRepl:[^,]+]]
3096-
// CHECK: [[codeRepl]]: ; preds = %entry
3096+
// CHECK: [[codeRepl]]:
30973097
// CHECK: %[[omp_global_thread_num:.+]] = call i32 @__kmpc_global_thread_num(ptr @{{.+}})
30983098
// CHECK: %[[final_flag:.+]] = select i1 %[[boolexpr]], i32 2, i32 0
30993099
// CHECK: %[[task_flags:.+]] = or i32 %[[final_flag]], 1

mlir/test/Target/LLVMIR/openmp-parallel-reduction-multiblock.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ llvm.func @missordered_blocks_(%arg0: !llvm.ptr {fir.bindc_name = "x"}, %arg1: !
3030

3131
// CHECK: %[[VAL_0:.*]] = alloca { ptr, ptr }, align 8
3232
// CHECK: br label %[[VAL_1:.*]]
33-
// CHECK: entry: ; preds = %[[VAL_2:.*]]
33+
// CHECK: [[VAL_1]]: ; preds = %[[VAL_2:.*]]
3434
// CHECK: %[[VAL_3:.*]] = call i32 @__kmpc_global_thread_num(ptr @1)
3535
// CHECK: br label %[[VAL_4:.*]]
3636
// CHECK: omp_parallel: ; preds = %[[VAL_1]]

0 commit comments

Comments
 (0)