[PATCH] D105061: [IR] Fix replaceUsesWithIf ponetial issue with constants
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 15:57:32 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb608053efb88: [IR] Fix replaceUsesWithIf ponetial issue with constants (authored by rampitec).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105061/new/
https://reviews.llvm.org/D105061
Files:
llvm/lib/IR/Value.cpp
Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -531,6 +531,9 @@
assert(New->getType() == getType() &&
"replaceUses of value with new value of different type!");
+ SmallVector<TrackingVH<Constant>, 8> Consts;
+ SmallPtrSet<Constant *, 8> Visited;
+
for (use_iterator UI = use_begin(), E = use_end(); UI != E;) {
Use &U = *UI;
++UI;
@@ -540,12 +543,19 @@
// constant because they are uniqued.
if (auto *C = dyn_cast<Constant>(U.getUser())) {
if (!isa<GlobalValue>(C)) {
- C->handleOperandChange(this, New);
+ if (Visited.insert(C).second)
+ Consts.push_back(TrackingVH<Constant>(C));
continue;
}
}
U.set(New);
}
+
+ while (!Consts.empty()) {
+ // FIXME: handleOperandChange() updates all the uses in a given Constant,
+ // not just the one passed to ShouldReplace
+ Consts.pop_back_val()->handleOperandChange(this, New);
+ }
}
/// Replace llvm.dbg.* uses of MetadataAsValue(ValueAsMetadata(V)) outside BB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105061.355055.patch
Type: text/x-patch
Size: 1129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/06907f58/attachment-0001.bin>
More information about the llvm-commits
mailing list