FunctionPass *llvm::createFastDeadStoreEliminationPass() { return new FDSE(); }
bool FDSE::runOnBasicBlock(BasicBlock &BB) {
- AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
// Record the last-seen store to this pointer
// Remove it!
MD.removeInstruction(last);
- AA.deleteValue(last);
// DCE instructions only used to calculate that store
if (Instruction* D = dyn_cast<Instruction>(last->getOperand(0)))
if (A == AliasAnalysis::MustAlias) {
// Remove it!
MD.removeInstruction(dependency);
- AA.deleteValue(dependency);
// DCE instructions only used to calculate that store
if (Instruction* D = dyn_cast<Instruction>(dependency->getOperand(0)))
if (deadPointers.count(S->getPointerOperand())){
// Remove it!
MD.removeInstruction(S);
- AA.deleteValue(S);
// DCE instructions only used to calculate that store
if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
// Let the memory dependence know
getAnalysis<MemoryDependenceAnalysis>().removeInstruction(I);
- getAnalysis<AliasAnalysis>().deleteValue(I);
// See if this made any operands dead. We do it this way in case the
// instruction uses the same operand twice. We don't want to delete a