mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Fix PR5258, jump-threading creating invalid PHIs.
When an incoming value for a PHI is updated, we must also updated all other incoming values for the same BB to match, otherwise we create invalid PHIs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84638 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -178,10 +178,18 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
|
||||
void SSAUpdater::RewriteUse(Use &U) {
|
||||
Instruction *User = cast<Instruction>(U.getUser());
|
||||
BasicBlock *UseBB = User->getParent();
|
||||
if (PHINode *UserPN = dyn_cast<PHINode>(User))
|
||||
PHINode *UserPN = dyn_cast<PHINode>(User);
|
||||
if (UserPN)
|
||||
UseBB = UserPN->getIncomingBlock(U);
|
||||
|
||||
U.set(GetValueInMiddleOfBlock(UseBB));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user