diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 21d83edbb18c4..c698d1babbf63 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -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(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 { diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 3e9705d61e8e0..74ebbcde57292 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -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. diff --git a/openmp/libomptarget/test/offloading/generic_multiple_parallel_regions.c b/openmp/libomptarget/test/offloading/generic_multiple_parallel_regions.c new file mode 100644 index 0000000000000..33fe2ca127b6d --- /dev/null +++ b/openmp/libomptarget/test/offloading/generic_multiple_parallel_regions.c @@ -0,0 +1,29 @@ +// RUN: %libomptarget-compile-run-and-check-generic +// RUN: %libomptarget-compileopt-run-and-check-generic + +#include +#include + +__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); +}