Author: resistor Date: Fri Jan 25 04:10:33 2008 New Revision: 46351 URL: http://llvm.org/viewvc/llvm-project?rev=46351&view=rev Log: DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
Added: llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=46351&r1=46350&r2=46351&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Jan 25 04:10:33 2008 @@ -261,9 +261,6 @@ 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 (!S->isVolatile()) { @@ -271,8 +268,12 @@ // See through pointer-to-pointer bitcasts TranslatePointerBitCasts(pointerOperand); - if (isa<AllocaInst>(pointerOperand) && - deadPointers.count(cast<AllocaInst>(pointerOperand))) { + // Alloca'd pointers or byval arguments (which are functionally like + // alloca's) are valid candidates for removal. + if ( (isa<AllocaInst>(pointerOperand) && + deadPointers.count(cast<AllocaInst>(pointerOperand))) || + (isa<Argument>(pointerOperand) && + cast<Argument>(pointerOperand)->hasByValAttr())) { // Remove it! MD.removeInstruction(S); Added: llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll?rev=46351&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll Fri Jan 25 04:10:33 2008 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep store + +%struct.x = type { i32, i32, i32, i32 } + +define i32 @foo(%struct.x* byval %a) nounwind { +entry: + %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 + store i32 1, i32* %tmp2, align 4 + ret i32 1 +} _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits