[llvm] 97387fd - [OpenMP] Fix carefully track SPMDCompatibilityTracker
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 20:50:44 PDT 2021
Author: Johannes Doerfert
Date: 2021-07-19T22:47:03-05:00
New Revision: 97387fdf6db43393aefddfd3cf90d04c5be735a8
URL: https://github.com/llvm/llvm-project/commit/97387fdf6db43393aefddfd3cf90d04c5be735a8
DIFF: https://github.com/llvm/llvm-project/commit/97387fdf6db43393aefddfd3cf90d04c5be735a8.diff
LOG: [OpenMP] Fix carefully track SPMDCompatibilityTracker
We did not properly use SPMDCompatibilityTracker in various places.
This patch makes sure we look at the validity properly and also fix
the state if we can.
Differential Revision: https://reviews.llvm.org/D106085
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 cc385b5f03c34..6862a3d2fcfea 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2759,7 +2759,7 @@ struct AAKernelInfoFunction : AAKernelInfo {
// __kmpc_target_init or
// __kmpc_target_deinit call. We will answer this one with the internal
// state.
- if (!isValidState())
+ if (!SPMDCompatibilityTracker.isValidState())
return nullptr;
if (!SPMDCompatibilityTracker.isAtFixpoint()) {
if (AA)
@@ -3162,20 +3162,22 @@ struct AAKernelInfoFunction : AAKernelInfo {
};
bool UsedAssumedInformationInCheckRWInst = false;
- if (!A.checkForAllReadWriteInstructions(
- CheckRWInst, *this, UsedAssumedInformationInCheckRWInst))
- SPMDCompatibilityTracker.indicatePessimisticFixpoint();
+ if (!SPMDCompatibilityTracker.isAtFixpoint())
+ if (!A.checkForAllReadWriteInstructions(
+ CheckRWInst, *this, UsedAssumedInformationInCheckRWInst))
+ SPMDCompatibilityTracker.indicatePessimisticFixpoint();
if (!IsKernelEntry)
updateReachingKernelEntries(A);
// Callback to check a call instruction.
+ bool AllSPMDStatesWereFixed = true;
auto CheckCallInst = [&](Instruction &I) {
auto &CB = cast<CallBase>(I);
auto &CBAA = A.getAAFor<AAKernelInfo>(
*this, IRPosition::callsite_function(CB), DepClassTy::OPTIONAL);
- if (CBAA.getState().isValidState())
- getState() ^= CBAA.getState();
+ getState() ^= CBAA.getState();
+ AllSPMDStatesWereFixed &= CBAA.SPMDCompatibilityTracker.isAtFixpoint();
return true;
};
@@ -3184,6 +3186,12 @@ struct AAKernelInfoFunction : AAKernelInfo {
CheckCallInst, *this, UsedAssumedInformationInCheckCallInst))
return indicatePessimisticFixpoint();
+ // If we haven't used any assumed information for the SPMD state we can fix
+ // it.
+ if (!UsedAssumedInformationInCheckRWInst &&
+ !UsedAssumedInformationInCheckCallInst && AllSPMDStatesWereFixed)
+ SPMDCompatibilityTracker.indicateOptimisticFixpoint();
+
return StateBefore == getState() ? ChangeStatus::UNCHANGED
: ChangeStatus::CHANGED;
}
More information about the llvm-commits
mailing list