[llvm] d3454ee - [AbstractAttributor] Fix two issues in folding __kmpc_is_spmd_exec_mode

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 17 10:13:50 PDT 2021


Author: Shilei Tian
Date: 2021-07-17T13:13:44-04:00
New Revision: d3454ee8d2f4f61723d0a02f15cce8b4d8886786

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

LOG: [AbstractAttributor] Fix two issues in folding __kmpc_is_spmd_exec_mode

This patch fixed two issues found when folding `__kmpc_is_spmd_exec_mode`:
1. When the reaching kernels are empty, it should not fold to generic mode.
2. When creating AA for the caller when updating information, the dependency
   should be required.

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D106209

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 68e63b1ab07d..cc385b5f03c3 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3196,8 +3196,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
 
       assert(Caller && "Caller is nullptr");
 
-      auto &CAA =
-          A.getOrCreateAAFor<AAKernelInfo>(IRPosition::function(*Caller));
+      auto &CAA = A.getOrCreateAAFor<AAKernelInfo>(
+          IRPosition::function(*Caller), this, DepClassTy::REQUIRED);
       if (CAA.ReachingKernelEntries.isValidState()) {
         ReachingKernelEntries ^= CAA.ReachingKernelEntries;
         return true;
@@ -3521,12 +3521,17 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall {
       // All reaching kernels are in SPMD mode. Update all function calls to
       // __kmpc_is_spmd_exec_mode to 1.
       SimplifiedValue = ConstantInt::get(Type::getInt8Ty(Ctx), true);
-    } else {
+    } else if (KnownNonSPMDCount || AssumedNonSPMDCount) {
       assert(KnownSPMDCount == 0 && AssumedSPMDCount == 0 &&
              "Expected only non-SPMD kernels!");
       // All reaching kernels are in non-SPMD mode. Update all function
       // calls to __kmpc_is_spmd_exec_mode to 0.
       SimplifiedValue = ConstantInt::get(Type::getInt8Ty(Ctx), false);
+    } else {
+      // We have empty reaching kernels, therefore we cannot tell if the
+      // associated call site can be folded. At this moment, SimplifiedValue
+      // must be none.
+      assert(!SimplifiedValue.hasValue() && "SimplifiedValue should be none");
     }
 
     return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED


        


More information about the llvm-commits mailing list