diff options
author | Alina Sbirlea <asbirlea@google.com> | 2019-02-26 19:44:52 +0000 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2019-02-26 19:44:52 +0000 |
commit | 9026404125bcb7b7a3f8e21c5536a1b60e9e07b6 (patch) | |
tree | f8fc03213683f0193c9c95b12789d0f3aef47d93 /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | 9b6135bf2a7aa2b9a79818671a5f12a98a41349f (diff) | |
download | bcm5719-llvm-9026404125bcb7b7a3f8e21c5536a1b60e9e07b6.tar.gz bcm5719-llvm-9026404125bcb7b7a3f8e21c5536a1b60e9e07b6.zip |
[MemorySSA & SimpleLoopUnswitch] Update MemorySSA in ReplaceUsesOfWith.
SimpleLoopUnswitch must update MemorySSA when removing instructions.
Resolves PR39197.
llvm-svn: 354919
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index 3bff0538be5..51d113eac89 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -1404,8 +1404,8 @@ static void RemoveFromWorklist(Instruction *I, /// When we find that I really equals V, remove I from the /// program, replacing all uses with V and update the worklist. static void ReplaceUsesOfWith(Instruction *I, Value *V, - std::vector<Instruction*> &Worklist, - Loop *L, LPPassManager *LPM) { + std::vector<Instruction *> &Worklist, Loop *L, + LPPassManager *LPM, MemorySSAUpdater *MSSAU) { LLVM_DEBUG(dbgs() << "Replace with '" << *V << "': " << *I << "\n"); // Add uses to the worklist, which may be dead now. @@ -1419,8 +1419,11 @@ static void ReplaceUsesOfWith(Instruction *I, Value *V, LPM->deleteSimpleAnalysisValue(I, L); RemoveFromWorklist(I, Worklist); I->replaceAllUsesWith(V); - if (!I->mayHaveSideEffects()) + if (!I->mayHaveSideEffects()) { + if (MSSAU) + MSSAU->removeMemoryAccess(I); I->eraseFromParent(); + } ++NumSimplify; } @@ -1595,7 +1598,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) { // 'false'. TODO: update the domtree properly so we can pass it here. if (Value *V = SimplifyInstruction(I, DL)) if (LI->replacementPreservesLCSSAForm(I, V)) { - ReplaceUsesOfWith(I, V, Worklist, L, LPM); + ReplaceUsesOfWith(I, V, Worklist, L, LPM, MSSAU.get()); continue; } @@ -1615,7 +1618,8 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) { // Resolve any single entry PHI nodes in Succ. while (PHINode *PN = dyn_cast<PHINode>(Succ->begin())) - ReplaceUsesOfWith(PN, PN->getIncomingValue(0), Worklist, L, LPM); + ReplaceUsesOfWith(PN, PN->getIncomingValue(0), Worklist, L, LPM, + MSSAU.get()); // If Succ has any successors with PHI nodes, update them to have // entries coming from Pred instead of Succ. |