Check void type before using RAUWd.

llvm-svn: 84049
This commit is contained in:
Devang Patel 2009-10-13 22:56:32 +00:00
parent fbd2d49398
commit a677136900
3 changed files with 27 additions and 7 deletions

View File

@ -9979,7 +9979,10 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
new StoreInst(ConstantInt::getTrue(*Context), new StoreInst(ConstantInt::getTrue(*Context),
UndefValue::get(Type::getInt1PtrTy(*Context)), UndefValue::get(Type::getInt1PtrTy(*Context)),
OldCall); OldCall);
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); // If OldCall dues not return void then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (OldCall->getType() != Type::getVoidTy(*Context))
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
if (isa<CallInst>(OldCall)) // Not worth removing an invoke here. if (isa<CallInst>(OldCall)) // Not worth removing an invoke here.
return EraseInstFromFunction(*OldCall); return EraseInstFromFunction(*OldCall);
return 0; return 0;
@ -9993,8 +9996,11 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
UndefValue::get(Type::getInt1PtrTy(*Context)), UndefValue::get(Type::getInt1PtrTy(*Context)),
CS.getInstruction()); CS.getInstruction());
CS.getInstruction()-> // If CS dues not return void then replaceAllUsesWith undef.
replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); // This allows ValueHandlers and custom metadata to adjust itself.
if (CS.getInstruction()->getType() != Type::getVoidTy(*Context))
CS.getInstruction()->
replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType()));
if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) { if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
// Don't break the CFG, insert a dummy cond branch. // Don't break the CFG, insert a dummy cond branch.
@ -12779,7 +12785,12 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
++NumDeadInst; ++NumDeadInst;
MadeIRChange = true; MadeIRChange = true;
} }
I->replaceAllUsesWith(UndefValue::get(I->getType()));
// If I is not void type then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (I->getType() != Type::getVoidTy(*Context))
I->replaceAllUsesWith(UndefValue::get(I->getType()));
I->eraseFromParent(); I->eraseFromParent();
} }
} }

View File

@ -487,7 +487,10 @@ void LICM::sink(Instruction &I) {
// Instruction is not used, just delete it. // Instruction is not used, just delete it.
CurAST->deleteValue(&I); CurAST->deleteValue(&I);
// If I has users in unreachable blocks, eliminate. // If I has users in unreachable blocks, eliminate.
I.replaceAllUsesWith(UndefValue::get(I.getType())); // If I is not void type then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (I.getType() != Type::getVoidTy(I.getContext()))
I.replaceAllUsesWith(UndefValue::get(I.getType()));
I.eraseFromParent(); I.eraseFromParent();
} else { } else {
// Move the instruction to the start of the exit block, after any PHI // Move the instruction to the start of the exit block, after any PHI
@ -500,7 +503,10 @@ void LICM::sink(Instruction &I) {
// The instruction is actually dead if there ARE NO exit blocks. // The instruction is actually dead if there ARE NO exit blocks.
CurAST->deleteValue(&I); CurAST->deleteValue(&I);
// If I has users in unreachable blocks, eliminate. // If I has users in unreachable blocks, eliminate.
I.replaceAllUsesWith(UndefValue::get(I.getType())); // If I is not void type then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (I.getType() != Type::getVoidTy(I.getContext()))
I.replaceAllUsesWith(UndefValue::get(I.getType()));
I.eraseFromParent(); I.eraseFromParent();
} else { } else {
// Otherwise, if we have multiple exits, use the PromoteMem2Reg function to // Otherwise, if we have multiple exits, use the PromoteMem2Reg function to

View File

@ -781,7 +781,10 @@ void LoopUnswitch::RemoveBlockIfDead(BasicBlock *BB,
// Anything that uses the instructions in this basic block should have their // Anything that uses the instructions in this basic block should have their
// uses replaced with undefs. // uses replaced with undefs.
I->replaceAllUsesWith(UndefValue::get(I->getType())); // If I is not void type then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (I->getType() != Type::getVoidTy(I->getContext()))
I->replaceAllUsesWith(UndefValue::get(I->getType()));
} }
// If this is the edge to the header block for a loop, remove the loop and // If this is the edge to the header block for a loop, remove the loop and