From 1cfdcae653140b1df5932767862a08f5a1b6106f Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 22 Jun 2021 16:58:13 -0400 Subject: [PATCH] [Attributor] Fix AAExecutionDomain returning true on invalid states This patch fixes a problem with the AAExecutionDomain attributor not checking if it is in a valid state. This can cause it to incorrectly return that a block is executed in a single threaded context after the attributor failed for any reason. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D103186 --- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 9822750..66901a69 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2311,7 +2311,7 @@ struct AAExecutionDomainFunction : public AAExecutionDomain { } bool isExecutedByInitialThreadOnly(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. @@ -2331,8 +2331,9 @@ ChangeStatus AAExecutionDomainFunction::updateImpl(Attributor &A) { const auto &ExecutionDomainAA = A.getAAFor( *this, IRPosition::function(*ACS.getInstruction()->getFunction()), DepClassTy::REQUIRED); - return ExecutionDomainAA.isExecutedByInitialThreadOnly( - *ACS.getInstruction()); + return ACS.isDirectCall() && + ExecutionDomainAA.isExecutedByInitialThreadOnly( + *ACS.getInstruction()); }; if (!A.checkForAllCallSites(PredForCallSite, *this, -- 2.7.4