Check void type before using RAUWd.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84049 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2009-10-13 22:56:32 +00:00
parent e72142aa5b
commit 228ebd0f4c
3 changed files with 27 additions and 7 deletions

View File

@@ -487,7 +487,10 @@ void LICM::sink(Instruction &I) {
// Instruction is not used, just delete it.
CurAST->deleteValue(&I);
// 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();
} else {
// 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.
CurAST->deleteValue(&I);
// 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();
} else {
// Otherwise, if we have multiple exits, use the PromoteMem2Reg function to