Skip to content

Commit d3454ee

Browse files
committed
[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
1 parent ca161e0 commit d3454ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,8 +3196,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
31963196

31973197
assert(Caller && "Caller is nullptr");
31983198

3199-
auto &CAA =
3200-
A.getOrCreateAAFor<AAKernelInfo>(IRPosition::function(*Caller));
3199+
auto &CAA = A.getOrCreateAAFor<AAKernelInfo>(
3200+
IRPosition::function(*Caller), this, DepClassTy::REQUIRED);
32013201
if (CAA.ReachingKernelEntries.isValidState()) {
32023202
ReachingKernelEntries ^= CAA.ReachingKernelEntries;
32033203
return true;
@@ -3521,12 +3521,17 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall {
35213521
// All reaching kernels are in SPMD mode. Update all function calls to
35223522
// __kmpc_is_spmd_exec_mode to 1.
35233523
SimplifiedValue = ConstantInt::get(Type::getInt8Ty(Ctx), true);
3524-
} else {
3524+
} else if (KnownNonSPMDCount || AssumedNonSPMDCount) {
35253525
assert(KnownSPMDCount == 0 && AssumedSPMDCount == 0 &&
35263526
"Expected only non-SPMD kernels!");
35273527
// All reaching kernels are in non-SPMD mode. Update all function
35283528
// calls to __kmpc_is_spmd_exec_mode to 0.
35293529
SimplifiedValue = ConstantInt::get(Type::getInt8Ty(Ctx), false);
3530+
} else {
3531+
// We have empty reaching kernels, therefore we cannot tell if the
3532+
// associated call site can be folded. At this moment, SimplifiedValue
3533+
// must be none.
3534+
assert(!SimplifiedValue.hasValue() && "SimplifiedValue should be none");
35303535
}
35313536

35323537
return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED

0 commit comments

Comments
 (0)