Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.389 -> 1.390 --- Log message: Before promoting a malloc type, remove dead uses. This makes instcombine more effective at promoting these allocations, catching them earlier in the compile process. --- Diffs of the changes: (+20 -0) InstructionCombining.cpp | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.389 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.390 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.389 Mon Oct 24 01:03:58 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 24 01:22:12 2005 @@ -3769,6 +3769,26 @@ const PointerType *PTy = dyn_cast<PointerType>(CI.getType()); if (AI.isArrayAllocation() || !PTy) return 0; + // Remove any uses of AI that are dead. + assert(!CI.use_empty() && "Dead instructions should be removed earlier!"); + std::vector<Instruction*> DeadUsers; + for (Value::use_iterator UI = AI.use_begin(), E = AI.use_end(); UI != E; ) { + Instruction *User = cast<Instruction>(*UI++); + if (isInstructionTriviallyDead(User)) { + while (UI != E && *UI == User) + ++UI; // If this instruction uses AI more than once, don't break UI. + + // Add operands to the worklist. + AddUsesToWorkList(*User); + ++NumDeadInst; + DEBUG(std::cerr << "IC: DCE: " << *User); + + User->eraseFromParent(); + removeFromWorkList(User); + } + } + + // Finally, if the instruction now has one use, delete it. if (!AI.hasOneUse()) return 0; // Get the type really allocated and the type casted to. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits