[llvm] 1cfdcae - [Attributor] Fix AAExecutionDomain returning true on invalid states

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 22 15:30:00 PDT 2021


Author: Joseph Huber
Date: 2021-06-22T18:12:43-04:00
New Revision: 1cfdcae653140b1df5932767862a08f5a1b6106f

URL: https://github.com/llvm/llvm-project/commit/1cfdcae653140b1df5932767862a08f5a1b6106f
DIFF: https://github.com/llvm/llvm-project/commit/1cfdcae653140b1df5932767862a08f5a1b6106f.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 9822750c69a9..66901a69df18 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<AAExecutionDomain>(
         *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,


        


More information about the llvm-commits mailing list