diff options
Diffstat (limited to 'llvm/lib/SandboxIR/Value.cpp')
-rw-r--r-- | llvm/lib/SandboxIR/Value.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/SandboxIR/Value.cpp b/llvm/lib/SandboxIR/Value.cpp index b9d91c7..e39bbc4 100644 --- a/llvm/lib/SandboxIR/Value.cpp +++ b/llvm/lib/SandboxIR/Value.cpp @@ -51,7 +51,7 @@ void Value::replaceUsesWithIf( llvm::Value *OtherVal = OtherV->Val; // We are delegating RUWIf to LLVM IR's RUWIf. Val->replaceUsesWithIf( - OtherVal, [&ShouldReplace, this](llvm::Use &LLVMUse) -> bool { + OtherVal, [&ShouldReplace, this, OtherV](llvm::Use &LLVMUse) -> bool { User *DstU = cast_or_null<User>(Ctx.getValue(LLVMUse.getUser())); if (DstU == nullptr) return false; @@ -59,6 +59,7 @@ void Value::replaceUsesWithIf( if (!ShouldReplace(UseToReplace)) return false; Ctx.getTracker().emplaceIfTracking<UseSet>(UseToReplace); + Ctx.runSetUseCallbacks(UseToReplace, OtherV); return true; }); } @@ -67,8 +68,9 @@ void Value::replaceAllUsesWith(Value *Other) { assert(getType() == Other->getType() && "Replacing with Value of different type!"); auto &Tracker = Ctx.getTracker(); - if (Tracker.isTracking()) { - for (auto Use : uses()) + for (auto Use : uses()) { + Ctx.runSetUseCallbacks(Use, Other); + if (Tracker.isTracking()) Tracker.track(std::make_unique<UseSet>(Use)); } // We are delegating RAUW to LLVM IR's RAUW. |