Skip to content

Commit

Permalink
[Attributor][FIX] Ensure new BBs are registered
Browse files Browse the repository at this point in the history
  • Loading branch information
jdoerfert committed Nov 1, 2023
1 parent 3426d33 commit a815208
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12405,11 +12405,14 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
Instruction *ThenTI =
SplitBlockAndInsertIfThen(LastCmp, IP, /* Unreachable */ false);
BasicBlock *CBBB = CB->getParent();
A.registerManifestAddedBasicBlock(*ThenTI->getParent());
A.registerManifestAddedBasicBlock(*CBBB);
auto *SplitTI = cast<BranchInst>(LastCmp->getNextNode());
BasicBlock *ElseBB;
if (IP == CB) {
ElseBB = BasicBlock::Create(ThenTI->getContext(), "",
ThenTI->getFunction(), CBBB);
A.registerManifestAddedBasicBlock(*ElseBB);
IP = BranchInst::Create(CBBB, ElseBB);
SplitTI->replaceUsesOfWith(CBBB, ElseBB);
} else {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4567,6 +4567,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
BasicBlock *PRNextBB =
BasicBlock::Create(Ctx, "worker_state_machine.parallel_region.check",
Kernel, StateMachineEndParallelBB);
A.registerManifestAddedBasicBlock(*PRExecuteBB);
A.registerManifestAddedBasicBlock(*PRNextBB);

// Check if we need to compare the pointer at all or if we can just
// call the parallel region function.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %libomptarget-compile-run-and-check-generic
// RUN: %libomptarget-compileopt-run-and-check-generic

#include <omp.h>
#include <stdio.h>

__attribute__((optnone)) void optnone() {}

int main() {
int i = 0;
#pragma omp target teams num_teams(1) map(tofrom : i)
{
optnone();
#pragma omp parallel
if (omp_get_thread_num() == 0)
++i;
#pragma omp parallel
if (omp_get_thread_num() == 0)
++i;
#pragma omp parallel
if (omp_get_thread_num() == 0)
++i;
#pragma omp parallel
if (omp_get_thread_num() == 0)
++i;
}
// CHECK: 4
printf("%i\n", i);
}

0 comments on commit a815208

Please sign in to comment.