[llvm-commits] [llvm] r84033 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp
Chris Lattner
clattner at apple.com
Tue Oct 13 14:50:01 PDT 2009
On Oct 13, 2009, at 2:41 PM, Devang Patel wrote:
> Author: dpatel
> Date: Tue Oct 13 16:41:20 2009
> New Revision: 84033
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84033&view=rev
> Log:
> Do not check use_empty() before replaceAllUsesWith(). This gives
> ValueHandles a chance to get properly updated.
Ok, but two requests:
1. please add a comment that this is updating the uses and the metadata.
2. The code may need to check to see that the call doesn't return
void. UndefValue::get(void) is not valid.
-Chris
>
>
> Modified:
> llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> llvm/trunk/lib/Transforms/Scalar/LICM.cpp
> llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84033&r1=84032&r2=84033&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue
> Oct 13 16:41:20 2009
> @@ -9979,8 +9979,7 @@
> new StoreInst(ConstantInt::getTrue(*Context),
> UndefValue::get(Type::getInt1PtrTy(*Context)),
> OldCall);
> - if (!OldCall->use_empty())
> - OldCall->replaceAllUsesWith(UndefValue::get(OldCall-
> >getType()));
> + OldCall->replaceAllUsesWith(UndefValue::get(OldCall-
> >getType()));
> if (isa<CallInst>(OldCall)) // Not worth removing an invoke
> here.
> return EraseInstFromFunction(*OldCall);
> return 0;
> @@ -9994,9 +9993,8 @@
> UndefValue::get(Type::getInt1PtrTy(*Context)),
> CS.getInstruction());
>
> - if (!CS.getInstruction()->use_empty())
> - CS.getInstruction()->
> - replaceAllUsesWith(UndefValue::get(CS.getInstruction()-
> >getType()));
> + CS.getInstruction()->
> + replaceAllUsesWith(UndefValue::get(CS.getInstruction()-
> >getType()));
>
> if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
> // Don't break the CFG, insert a dummy cond branch.
> @@ -10251,7 +10249,7 @@
> }
> }
>
> -
> +
> if (!Caller->use_empty())
> Caller->replaceAllUsesWith(NV);
>
> @@ -10398,7 +10396,7 @@
> setCallingConv(cast<CallInst>(Caller)->getCallingConv());
> cast<CallInst>(NewCaller)->setAttributes(NewPAL);
> }
> - if (Caller->getType() != Type::getVoidTy(*Context) && !Caller-
> >use_empty())
> + if (Caller->getType() != Type::getVoidTy(*Context))
> Caller->replaceAllUsesWith(NewCaller);
> Caller->eraseFromParent();
> Worklist.Remove(Caller);
> @@ -12781,8 +12779,7 @@
> ++NumDeadInst;
> MadeIRChange = true;
> }
> - if (!I->use_empty())
> - I->replaceAllUsesWith(UndefValue::get(I->getType()));
> + I->replaceAllUsesWith(UndefValue::get(I->getType()));
> I->eraseFromParent();
> }
> }
>
> Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84033&r1=84032&r2=84033&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 16:41:20 2009
> @@ -486,8 +486,8 @@
> if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0],
> I.getParent())) {
> // Instruction is not used, just delete it.
> CurAST->deleteValue(&I);
> - if (!I.use_empty()) // If I has users in unreachable blocks,
> eliminate.
> - I.replaceAllUsesWith(UndefValue::get(I.getType()));
> + // If I has users in unreachable blocks, eliminate.
> + I.replaceAllUsesWith(UndefValue::get(I.getType()));
> I.eraseFromParent();
> } else {
> // Move the instruction to the start of the exit block, after
> any PHI
> @@ -499,8 +499,8 @@
> } else if (ExitBlocks.empty()) {
> // The instruction is actually dead if there ARE NO exit blocks.
> CurAST->deleteValue(&I);
> - if (!I.use_empty()) // If I has users in unreachable blocks,
> eliminate.
> - I.replaceAllUsesWith(UndefValue::get(I.getType()));
> + // If I has users in unreachable blocks, eliminate.
> + I.replaceAllUsesWith(UndefValue::get(I.getType()));
> I.eraseFromParent();
> } else {
> // Otherwise, if we have multiple exits, use the PromoteMem2Reg
> function to
>
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84033&r1=84032&r2=84033&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13
> 16:41:20 2009
> @@ -781,8 +781,7 @@
>
> // Anything that uses the instructions in this basic block
> should have their
> // uses replaced with undefs.
> - if (!I->use_empty())
> - I->replaceAllUsesWith(UndefValue::get(I->getType()));
> + I->replaceAllUsesWith(UndefValue::get(I->getType()));
> }
>
> // If this is the edge to the header block for a loop, remove the
> loop and
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list