[PATCH] D109662: [Attributor] Ensure store uses are correlated with reloads
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 28 21:54:09 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e2fcf8513a3: [Attributor][FIX] Ensure store uses are correlated with reloads (authored by jdoerfert).
Changed prior to commit:
https://reviews.llvm.org/D109662?vs=373310&id=396472#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109662/new/
https://reviews.llvm.org/D109662
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1293,8 +1293,15 @@
LLVM_DEBUG(dbgs() << "[AAPointerInfo] User not handled " << *Usr << "\n");
return false;
};
+ auto EquivalentUseCB = [&](const Use &OldU, const Use &NewU) {
+ if (OffsetInfoMap.count(NewU))
+ return OffsetInfoMap[NewU] == OffsetInfoMap[OldU];
+ OffsetInfoMap[NewU] = OffsetInfoMap[OldU];
+ return true;
+ };
if (!A.checkForAllUses(UsePred, *this, AssociatedValue,
- /* CheckBBLivenessOnly */ true))
+ /* CheckBBLivenessOnly */ true, DepClassTy::OPTIONAL,
+ EquivalentUseCB))
return indicatePessimisticFixpoint();
LLVM_DEBUG({
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -999,10 +999,11 @@
return false;
}
-bool Attributor::checkForAllUses(function_ref<bool(const Use &, bool &)> Pred,
- const AbstractAttribute &QueryingAA,
- const Value &V, bool CheckBBLivenessOnly,
- DepClassTy LivenessDepClass) {
+bool Attributor::checkForAllUses(
+ function_ref<bool(const Use &, bool &)> Pred,
+ const AbstractAttribute &QueryingAA, const Value &V,
+ bool CheckBBLivenessOnly, DepClassTy LivenessDepClass,
+ function_ref<bool(const Use &OldU, const Use &NewU)> EquivalentUseCB) {
// Check the trivial case first as it catches void values.
if (V.use_empty())
@@ -1053,8 +1054,15 @@
<< PotentialCopies.size()
<< " potential copies instead!\n");
for (Value *PotentialCopy : PotentialCopies)
- for (const Use &U : PotentialCopy->uses())
- Worklist.push_back(&U);
+ for (const Use &CopyUse : PotentialCopy->uses()) {
+ if (EquivalentUseCB && !EquivalentUseCB(*U, CopyUse)) {
+ LLVM_DEBUG(dbgs() << "[Attributor] Potential copy was "
+ "rejected by the equivalence call back: "
+ << *CopyUse << "!\n");
+ return false;
+ }
+ Worklist.push_back(&CopyUse);
+ }
continue;
}
}
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1623,10 +1623,17 @@
///
/// This method will evaluate \p Pred on all (transitive) uses of the
/// associated value and return true if \p Pred holds every time.
+ /// If uses are skipped in favor of equivalent ones, e.g., if we look through
+ /// memory, the \p EquivalentUseCB will be used to give the caller an idea
+ /// what original used was replaced by a new one (or new ones). The visit is
+ /// cut short if \p EquivalentUseCB returns false and the function will return
+ /// false as well.
bool checkForAllUses(function_ref<bool(const Use &, bool &)> Pred,
const AbstractAttribute &QueryingAA, const Value &V,
bool CheckBBLivenessOnly = false,
- DepClassTy LivenessDepClass = DepClassTy::OPTIONAL);
+ DepClassTy LivenessDepClass = DepClassTy::OPTIONAL,
+ function_ref<bool(const Use &OldU, const Use &NewU)>
+ EquivalentUseCB = nullptr);
/// Emit a remark generically.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109662.396472.patch
Type: text/x-patch
Size: 3886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211229/8a9befb0/attachment.bin>
More information about the llvm-commits
mailing list