Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.412 -> 1.413 --- Log message: Do a simple instcombine xforms to delete llvm.stackrestore cases. --- Diffs of the changes: (+33 -0) InstructionCombining.cpp | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.412 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.412 Fri Jan 13 14:11:04 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 13 15:28:09 2006 @@ -4671,6 +4671,39 @@ SPI->replaceAllUsesWith(PrevSPI); return EraseInstFromFunction(CI); } + } else { + switch (II->getIntrinsicID()) { + default: break; + case Intrinsic::stackrestore: { + // If the save is right next to the restore, remove the restore. This can + // happen when variable allocas are DCE'd. + if (IntrinsicInst *SS = dyn_cast<IntrinsicInst>(II->getOperand(1))) { + if (SS->getIntrinsicID() == Intrinsic::stacksave) { + BasicBlock::iterator BI = SS; + if (&*++BI == II) + return EraseInstFromFunction(CI); + } + } + + // If the stack restore is in a return/unwind block and if there are no + // allocas or calls between the restore and the return, nuke the restore. + TerminatorInst *TI = II->getParent()->getTerminator(); + if (isa<ReturnInst>(TI) || isa<UnwindInst>(TI)) { + BasicBlock::iterator BI = II; + bool CannotRemove = false; + for (++BI; &*BI != TI; ++BI) { + if (isa<AllocaInst>(BI) || + (isa<CallInst>(BI) && !isa<IntrinsicInst>(BI))) { + CannotRemove = true; + break; + } + } + if (!CannotRemove) + return EraseInstFromFunction(CI); + } + break; + } + } } return visitCallSite(II); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits