1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

When re-using an existing cast for a user, it's still necessary to call

rememberInstruction so that future users of that user will be inserted
in the correct position. This fixes the Darwin selfhost.

llvm-svn: 94070
This commit is contained in:
Dan Gohman 2010-01-21 10:08:42 +00:00
parent 938b8b195c
commit 7bd5379b8c

View File

@ -98,14 +98,16 @@ Value *SCEVExpander::InsertNoopCastOfTo(Value *V, const Type *Ty) {
It = cast<InvokeInst>(I)->getNormalDest()->begin();
while (isa<PHINode>(It)) ++It;
if (It != BasicBlock::iterator(CI)) {
// Recreate the cast at the beginning of the entry block.
// Recreate the cast after the user.
// The old cast is left in place in case it is being used
// as an insert point.
Instruction *NewCI = CastInst::Create(Op, V, Ty, "", It);
NewCI->takeName(CI);
CI->replaceAllUsesWith(NewCI);
rememberInstruction(NewCI);
return NewCI;
}
rememberInstruction(CI);
return CI;
}
}