[PATCH] D100079: [Attributor] Don't modify functions outside of the current SCC
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 17:10:00 PDT 2021
aeubanks created this revision.
Herald added a reviewer: uenoku.
Herald added subscribers: okura, kuter, uenoku.
Herald added a reviewer: homerdin.
aeubanks requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added subscribers: llvm-commits, bbn.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100079
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1331,6 +1331,8 @@
/// Record that \p U is to be replaces with \p NV after information was
/// manifested. This also triggers deletion of trivially dead istructions.
bool changeUseAfterManifest(Use &U, Value &NV) {
+ if (!canChangeUse(U))
+ return false;
Value *&V = ToBeChangedUses[&U];
if (V && (V->stripPointerCasts() == NV.stripPointerCasts() ||
isa_and_nonnull<UndefValue>(V)))
@@ -1341,6 +1343,14 @@
return true;
}
+ bool canChangeUse(Use &U) {
+ if (Functions.empty())
+ return true;
+ if (auto *I = dyn_cast<Instruction>(U.getUser()))
+ return Functions.contains(I->getParent()->getParent());
+ return false;
+ }
+
/// Helper function to replace all uses of \p V with \p NV. Return true if
/// there is any change. The flag \p ChangeDroppable indicates if dropppable
/// uses should be changed too.
@@ -1348,7 +1358,7 @@
bool ChangeDroppable = true) {
bool Changed = false;
for (auto &U : V.uses())
- if (ChangeDroppable || !U.getUser()->isDroppable())
+ if ((ChangeDroppable || !U.getUser()->isDroppable()) && canChangeUse(U))
Changed |= changeUseAfterManifest(U, NV);
return Changed;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100079.335963.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/4a4ab8ea/attachment.bin>
More information about the llvm-commits
mailing list