[llvm-commits] [llvm] r39788 - /llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
Owen Anderson
resistor at mac.com
Thu Jul 12 10:52:21 PDT 2007
Author: resistor
Date: Thu Jul 12 12:52:20 2007
New Revision: 39788
URL: http://llvm.org/viewvc/llvm-project?rev=39788&view=rev
Log:
Remove the end-block handling code. It was unsafe, and making it safe would have resulted in falling back to the slow DSE case. I need to think some more about the right way to handle this.
Modified:
llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp?rev=39788&r1=39787&r2=39788&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp Thu Jul 12 12:52:20 2007
@@ -122,11 +122,6 @@
}
}
- // If this block ends in a return, unwind, unreachable, and eventually
- // tailcall, then all allocas are dead at its end.
- if (BB.getTerminator()->getNumSuccessors() == 0)
- MadeChange |= handleEndBlock(BB, possiblyDead);
-
// Do a trivial DCE
while (!possiblyDead.empty()) {
Instruction *I = possiblyDead.back();
@@ -168,56 +163,6 @@
return false;
}
-/// handleEndBlock - Remove dead stores to stack-allocated locations in the function
-/// end block
-bool FDSE::handleEndBlock(BasicBlock& BB, SetVector<Instruction*>& possiblyDead) {
- MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
-
- bool MadeChange = false;
-
- // Pointers alloca'd in this function are dead in the end block
- SmallPtrSet<AllocaInst*, 4> deadPointers;
-
- // Find all of the alloca'd pointers in the entry block
- BasicBlock *Entry = BB.getParent()->begin();
- for (BasicBlock::iterator I = Entry->begin(), E = Entry->end(); I != E; ++I)
- if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
- deadPointers.insert(AI);
-
- // Scan the basic block backwards
- for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){
- --BBI;
-
- if (deadPointers.empty())
- break;
-
- // If we find a store whose pointer is dead...
- if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
- if (deadPointers.count(S->getPointerOperand())){
- // Remove it!
- MD.removeInstruction(S);
-
- // DCE instructions only used to calculate that store
- if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
- possiblyDead.insert(D);
-
- BBI++;
- S->eraseFromParent();
- NumFastStores++;
- MadeChange = true;
- }
-
- // If we encounter a use of the pointer, it is no longer considered dead
- } else if (LoadInst* L = dyn_cast<LoadInst>(BBI)) {
- deadPointers.erase(L->getPointerOperand());
- } else if (VAArgInst* V = dyn_cast<VAArgInst>(BBI)) {
- deadPointers.erase(V->getOperand(0));
- }
- }
-
- return MadeChange;
-}
-
void FDSE::DeleteDeadInstructionChains(Instruction *I,
SetVector<Instruction*> &DeadInsts) {
// Instruction must be dead.
More information about the llvm-commits
mailing list