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 @@ -2319,7 +2319,7 @@ } bool isSingleThreadExecution(const BasicBlock &BB) const override { - return SingleThreadedBBs.contains(&BB); + return isValidState() && SingleThreadedBBs.contains(&BB); } /// Set of basic blocks that are executed by a single thread. @@ -2339,7 +2339,8 @@ const auto &ExecutionDomainAA = A.getAAFor( *this, IRPosition::function(*ACS.getInstruction()->getFunction()), DepClassTy::REQUIRED); - return ExecutionDomainAA.isSingleThreadExecution(*ACS.getInstruction()); + return ACS.isDirectCall() && + ExecutionDomainAA.isSingleThreadExecution(*ACS.getInstruction()); }; if (!A.checkForAllCallSites(PredForCallSite, *this,