summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemorySSAUpdater.cpp
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/Analysis/MemorySSAUpdater.cpp
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/Analysis/MemorySSAUpdater.cpp')
-rw-r--r--llvm/lib/Analysis/MemorySSAUpdater.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index 7fea41a8a53..39882dab04c 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -267,17 +267,14 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
// before.
// We now define that def's memorydefs and memoryphis
if (DefBeforeSameBlock) {
- for (auto UI = DefBefore->use_begin(), UE = DefBefore->use_end();
- UI != UE;) {
- Use &U = *UI++;
+ DefBefore->replaceUsesWithIf(MD, [MD](Use &U) {
// Leave the MemoryUses alone.
// Also make sure we skip ourselves to avoid self references.
- if (isa<MemoryUse>(U.getUser()) || U.getUser() == MD)
- continue;
+ User *Usr = U.getUser();
+ return !isa<MemoryUse>(Usr) && Usr != MD;
// Defs are automatically unoptimized when the user is set to MD below,
// because the isOptimized() call will fail to find the same ID.
- U.set(MD);
- }
+ });
}
// and that def is now our defining access.
OpenPOWER on IntegriCloud