Revert "[PR16756] Use SSAUpdaterBulk in JumpThreading."

This reverts commit r329644.

llvm-svn: 329650
This commit is contained in:
Michael Zolotukhin 2018-04-10 00:42:43 +00:00
parent d829973794
commit 0274632ee6
1 changed files with 13 additions and 18 deletions

View File

@ -66,7 +66,6 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/SSAUpdater.h" #include "llvm/Transforms/Utils/SSAUpdater.h"
#include "llvm/Transforms/Utils/SSAUpdaterBulk.h"
#include "llvm/Transforms/Utils/ValueMapper.h" #include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -1990,13 +1989,9 @@ bool JumpThreadingPass::ThreadEdge(BasicBlock *BB,
// now have to update all uses of the value to use either the original value, // now have to update all uses of the value to use either the original value,
// the cloned value, or some PHI derived value. This can require arbitrary // the cloned value, or some PHI derived value. This can require arbitrary
// PHI insertion, of which we are prepared to do, clean these up now. // PHI insertion, of which we are prepared to do, clean these up now.
SSAUpdaterBulk SSAUpdate; SSAUpdater SSAUpdate;
SmallVector<Use*, 16> UsesToRename; SmallVector<Use*, 16> UsesToRename;
unsigned VarNum = 0;
for (Instruction &I : *BB) { for (Instruction &I : *BB) {
UsesToRename.clear();
// Scan all uses of this instruction to see if it is used outside of its // Scan all uses of this instruction to see if it is used outside of its
// block, and if so, record them in UsesToRename. // block, and if so, record them in UsesToRename.
for (Use &U : I.uses()) { for (Use &U : I.uses()) {
@ -2013,15 +2008,19 @@ bool JumpThreadingPass::ThreadEdge(BasicBlock *BB,
// If there are no uses outside the block, we're done with this instruction. // If there are no uses outside the block, we're done with this instruction.
if (UsesToRename.empty()) if (UsesToRename.empty())
continue; continue;
SSAUpdate.AddVariable(VarNum, I.getName(), I.getType());
// We found a use of I outside of BB - we need to rename all uses of I that DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n");
// are outside its block to be uses of the appropriate PHI node etc.
SSAUpdate.AddAvailableValue(VarNum, BB, &I); // We found a use of I outside of BB. Rename all uses of I that are outside
SSAUpdate.AddAvailableValue(VarNum, NewBB, ValueMapping[&I]); // its block to be uses of the appropriate PHI node etc. See ValuesInBlocks
for (auto U : UsesToRename) // with the two values we know.
SSAUpdate.AddUse(VarNum, U); SSAUpdate.Initialize(I.getType(), I.getName());
VarNum++; SSAUpdate.AddAvailableValue(BB, &I);
SSAUpdate.AddAvailableValue(NewBB, ValueMapping[&I]);
while (!UsesToRename.empty())
SSAUpdate.RewriteUse(*UsesToRename.pop_back_val());
DEBUG(dbgs() << "\n");
} }
// Ok, NewBB is good to go. Update the terminator of PredBB to jump to // Ok, NewBB is good to go. Update the terminator of PredBB to jump to
@ -2038,10 +2037,6 @@ bool JumpThreadingPass::ThreadEdge(BasicBlock *BB,
{DominatorTree::Insert, PredBB, NewBB}, {DominatorTree::Insert, PredBB, NewBB},
{DominatorTree::Delete, PredBB, BB}}); {DominatorTree::Delete, PredBB, BB}});
// Apply all updates we queued with DDT and get the updated Dominator Tree.
DominatorTree *DT = &DDT->flush();
SSAUpdate.RewriteAllUses(DT);
// At this point, the IR is fully up to date and consistent. Do a quick scan // At this point, the IR is fully up to date and consistent. Do a quick scan
// over the new instructions and zap any that are constants or dead. This // over the new instructions and zap any that are constants or dead. This
// frequently happens because of phi translation. // frequently happens because of phi translation.