summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SafeStack.cpp
diff options
context:
space:
mode:
authorWhitney Tsang <whitney.uwaterloo@gmail.com>2019-06-17 14:38:56 +0000
committerWhitney Tsang <whitney.uwaterloo@gmail.com>2019-06-17 14:38:56 +0000
commit15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6 (patch)
treefdc3c71b9334ee77ede0ec010ac2269a03d24651 /llvm/lib/CodeGen/SafeStack.cpp
parent1c91e63897d8832a7b634d9662b8dbcc3ba36efd (diff)
downloadbcm5719-llvm-15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6.tar.gz
bcm5719-llvm-15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6.zip
PHINode: introduce setIncomingValueForBlock() function, and use it.
Summary: There is PHINode::getBasicBlockIndex() and PHINode::setIncomingValue() but no function to replace incoming value for a specified BasicBlock* predecessor. Clearly, there are a lot of places that could use that functionality. Reviewer: craig.topper, lebedev.ri, Meinersbur, kbarton, fhahn Reviewed By: Meinersbur, fhahn Subscribers: fhahn, hiraditya, zzheng, jsji, llvm-commits Tag: LLVM Differential Revision: https://reviews.llvm.org/D63338 llvm-svn: 363566
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r--llvm/lib/CodeGen/SafeStack.cpp10
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();
OpenPOWER on IntegriCloud