summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-08-01 12:32:08 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-08-01 12:32:08 +0000
commit081e990d08523f290f3d6cfe8ff677a57f546bc4 (patch)
treef054298e9cb5f813c39c9390b0be848448c3c65d /llvm/lib/Target/WebAssembly
parent0efeaa81626f4c972a1f792f2b2daea1ad2eb4f5 (diff)
downloadbcm5719-llvm-081e990d08523f290f3d6cfe8ff677a57f546bc4.tar.gz
bcm5719-llvm-081e990d08523f290f3d6cfe8ff677a57f546bc4.zip
[IR] Value: add replaceUsesWithIf() utility
Summary: While there is always a `Value::replaceAllUsesWith()`, sometimes the replacement needs to be conditional. I have only cleaned a few cases where `replaceUsesWithIf()` could be used, to both add test coverage, and show that it is actually useful. Reviewers: jdoerfert, spatel, RKSimon, craig.topper Reviewed By: jdoerfert Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, aheejin, george.burgess.iv, asbirlea, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65528 llvm-svn: 367548
Diffstat (limited to 'llvm/lib/Target/WebAssembly')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp
index d20352259e0..9b60596e42b 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp
@@ -64,11 +64,8 @@ void OptimizeReturned::visitCallSite(CallSite CS) {
if (isa<Constant>(Arg))
continue;
// Like replaceDominatedUsesWith but using Instruction/Use dominance.
- for (auto UI = Arg->use_begin(), UE = Arg->use_end(); UI != UE;) {
- Use &U = *UI++;
- if (DT->dominates(Inst, U))
- U.set(Inst);
- }
+ Arg->replaceUsesWithIf(Inst,
+ [&](Use &U) { return DT->dominates(Inst, U); });
}
}
OpenPOWER on IntegriCloud