[PATCH] D106209: [AbstractAttributor] Fix two issues in folding __kmpc_is_spmd_exec_mode
Shilei Tian via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 20:45:20 PDT 2021
tianshilei1992 created this revision.
Herald added subscribers: ormris, okura, uenoku, hiraditya.
Herald added a reviewer: uenoku.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added subscribers: llvm-commits, bbn, sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106209
Files:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3196,8 +3196,8 @@
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,16 @@
// 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.
+ SimplifiedValue = nullptr;
}
return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106209.359525.patch
Type: text/x-patch
Size: 1477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210717/78c8cc66/attachment.bin>
More information about the llvm-commits
mailing list