Skip to content

Commit a815208

Browse files
committed
[Attributor][FIX] Ensure new BBs are registered
1 parent 3426d33 commit a815208

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12405,11 +12405,14 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1240512405
Instruction *ThenTI =
1240612406
SplitBlockAndInsertIfThen(LastCmp, IP, /* Unreachable */ false);
1240712407
BasicBlock *CBBB = CB->getParent();
12408+
A.registerManifestAddedBasicBlock(*ThenTI->getParent());
12409+
A.registerManifestAddedBasicBlock(*CBBB);
1240812410
auto *SplitTI = cast<BranchInst>(LastCmp->getNextNode());
1240912411
BasicBlock *ElseBB;
1241012412
if (IP == CB) {
1241112413
ElseBB = BasicBlock::Create(ThenTI->getContext(), "",
1241212414
ThenTI->getFunction(), CBBB);
12415+
A.registerManifestAddedBasicBlock(*ElseBB);
1241312416
IP = BranchInst::Create(CBBB, ElseBB);
1241412417
SplitTI->replaceUsesOfWith(CBBB, ElseBB);
1241512418
} else {

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,6 +4567,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
45674567
BasicBlock *PRNextBB =
45684568
BasicBlock::Create(Ctx, "worker_state_machine.parallel_region.check",
45694569
Kernel, StateMachineEndParallelBB);
4570+
A.registerManifestAddedBasicBlock(*PRExecuteBB);
4571+
A.registerManifestAddedBasicBlock(*PRNextBB);
45704572

45714573
// Check if we need to compare the pointer at all or if we can just
45724574
// call the parallel region function.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %libomptarget-compile-run-and-check-generic
2+
// RUN: %libomptarget-compileopt-run-and-check-generic
3+
4+
#include <omp.h>
5+
#include <stdio.h>
6+
7+
__attribute__((optnone)) void optnone() {}
8+
9+
int main() {
10+
int i = 0;
11+
#pragma omp target teams num_teams(1) map(tofrom : i)
12+
{
13+
optnone();
14+
#pragma omp parallel
15+
if (omp_get_thread_num() == 0)
16+
++i;
17+
#pragma omp parallel
18+
if (omp_get_thread_num() == 0)
19+
++i;
20+
#pragma omp parallel
21+
if (omp_get_thread_num() == 0)
22+
++i;
23+
#pragma omp parallel
24+
if (omp_get_thread_num() == 0)
25+
++i;
26+
}
27+
// CHECK: 4
28+
printf("%i\n", i);
29+
}

0 commit comments

Comments
 (0)