diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -3233,8 +3233,7 @@ auto &CB = cast(I); auto &CBAA = A.getAAFor( *this, IRPosition::callsite_function(CB), DepClassTy::OPTIONAL); - if (CBAA.getState().isValidState()) - getState() ^= CBAA.getState(); + getState() ^= CBAA.getState(); Function *Callee = CB.getCalledFunction(); if (Callee) { @@ -3270,7 +3269,7 @@ auto &CAA = A.getOrCreateAAFor(IRPosition::function(*Caller)); - if (CAA.isValidState()) { + if (CAA.ReachingKernelEntries.isValidState()) { ReachingKernelEntries ^= CAA.ReachingKernelEntries; return true; } @@ -3536,6 +3535,11 @@ return Changed; } + ChangeStatus indicatePessimisticFixpoint() override { + SimplifiedValue = nullptr; + return AAFoldRuntimeCall::indicateOptimisticFixpoint(); + } + private: /// Fold __kmpc_is_spmd_exec_mode into a constant if possible. ChangeStatus foldIsSPMDExecMode(Attributor &A) { @@ -3546,6 +3550,9 @@ auto &CallerKernelInfoAA = A.getAAFor( *this, IRPosition::function(*getAnchorScope()), DepClassTy::REQUIRED); + if (!CallerKernelInfoAA.ReachingKernelEntries.isValidState()) + return indicatePessimisticFixpoint(); + for (Kernel K : CallerKernelInfoAA.ReachingKernelEntries) { auto &AA = A.getAAFor(*this, IRPosition::function(*K), DepClassTy::REQUIRED);