summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-05-23 13:36:25 +0000
committerAnna Thomas <anna@azul.com>2017-05-23 13:36:25 +0000
commitc07d5544dde0cc6e1d844028d82aa2cf1dc8066a (patch)
tree0417d53c3fb6d2126732b357a23f41491058daa4 /llvm/lib/Transforms/Utils/Local.cpp
parentb6d40cceeed08876e6d633099de7c5c15f66c453 (diff)
downloadbcm5719-llvm-c07d5544dde0cc6e1d844028d82aa2cf1dc8066a.tar.gz
bcm5719-llvm-c07d5544dde0cc6e1d844028d82aa2cf1dc8066a.zip
[JumpThreading] Safely replace uses of condition
This patch builds over https://reviews.llvm.org/rL303349 and replaces the use of the condition only if it is safe to do so. We should not blindly RAUW the condition if experimental.guard or assume is a use of that condition. This is because LVI may have used the guard/assume to identify the value of the condition, and RUAWing will fold the guard/assume and uses before the guards/assumes. Reviewers: sanjoy, reames, trentxintong, mkazantsev Reviewed by: sanjoy, reames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33257 llvm-svn: 303633
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 1ca509472b5..29f67a8f53b 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1796,6 +1796,23 @@ static unsigned replaceDominatedUsesWith(Value *From, Value *To,
return Count;
}
+unsigned llvm::replaceNonLocalUsesWith(Instruction *From, Value *To) {
+ assert(From->getType() == To->getType());
+ auto *BB = From->getParent();
+ unsigned Count = 0;
+
+ for (Value::use_iterator UI = From->use_begin(), UE = From->use_end();
+ UI != UE;) {
+ Use &U = *UI++;
+ auto *I = cast<Instruction>(U.getUser());
+ if (I->getParent() == BB)
+ continue;
+ U.set(To);
+ ++Count;
+ }
+ return Count;
+}
+
unsigned llvm::replaceDominatedUsesWith(Value *From, Value *To,
DominatorTree &DT,
const BasicBlockEdge &Root) {
OpenPOWER on IntegriCloud