diff options
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SafeStack.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp index b73a22133a7..6ee5df42407 100644 --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -613,16 +613,12 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack( ConstantInt::get(Int32Ty, -Offset)); Value *Replacement = IRBUser.CreateBitCast(Off, AI->getType(), Name); - if (auto *PHI = dyn_cast<PHINode>(User)) { + if (auto *PHI = dyn_cast<PHINode>(User)) // PHI nodes may have multiple incoming edges from the same BB (why??), // all must be updated at once with the same incoming value. - auto *BB = PHI->getIncomingBlock(U); - for (unsigned I = 0; I < PHI->getNumIncomingValues(); ++I) - if (PHI->getIncomingBlock(I) == BB) - PHI->setIncomingValue(I, Replacement); - } else { + PHI->setIncomingValueForBlock(PHI->getIncomingBlock(U), Replacement); + else U.set(Replacement); - } } AI->eraseFromParent(); |