alternate fix for PR5258 which avoids worklist problems, with reduced testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-10-20 20:27:49 +00:00
parent 18ed9c9a2b
commit 88a8624f8e
3 changed files with 41 additions and 359 deletions

View File

@ -177,19 +177,14 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
/// which use their value in the corresponding predecessor.
void SSAUpdater::RewriteUse(Use &U) {
Instruction *User = cast<Instruction>(U.getUser());
BasicBlock *UseBB = User->getParent();
PHINode *UserPN = dyn_cast<PHINode>(User);
if (UserPN)
UseBB = UserPN->getIncomingBlock(U);
Value *V;
if (PHINode *UserPN = dyn_cast<PHINode>(User))
V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
else
V = GetValueInMiddleOfBlock(User->getParent());
Value *V = GetValueInMiddleOfBlock(UseBB);
U.set(V);
if (UserPN) {
// Incoming value from the same BB must be consistent
for (unsigned i=0;i<UserPN->getNumIncomingValues();i++)
if (UserPN->getIncomingBlock(i) == UseBB)
UserPN->setIncomingValue(i, V);
}
}