aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SSAUpdater.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-29 04:54:06 +0000
committerChris Lattner <sabre@nondot.org>2010-08-29 04:54:06 +0000
commitffd9beefb8d1fc854fc2863ad443a557be2b4196 (patch)
tree7c111de2ee10544739e1b3d19b71fc6892aadc53 /lib/Transforms/Utils/SSAUpdater.cpp
parentabd2a7590061019c95b2f325f813bbea9bb79924 (diff)
implement SSAUpdater::RewriteUseAfterInsertions, a helpful form of RewriteUse.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SSAUpdater.cpp')
-rw-r--r--lib/Transforms/Utils/SSAUpdater.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp
index f4bdb52765..9dc2a1ed38 100644
--- a/lib/Transforms/Utils/SSAUpdater.cpp
+++ b/lib/Transforms/Utils/SSAUpdater.cpp
@@ -205,6 +205,22 @@ void SSAUpdater::RewriteUse(Use &U) {
U.set(V);
}
+/// RewriteUseAfterInsertions - Rewrite a use, just like RewriteUse. However,
+/// this version of the method can rewrite uses in the same block as a
+/// definition, because it assumes that all uses of a value are below any
+/// inserted values.
+void SSAUpdater::RewriteUseAfterInsertions(Use &U) {
+ Instruction *User = cast<Instruction>(U.getUser());
+
+ Value *V;
+ if (PHINode *UserPN = dyn_cast<PHINode>(User))
+ V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
+ else
+ V = GetValueAtEndOfBlock(User->getParent());
+
+ U.set(V);
+}
+
/// PHIiter - Iterator for PHI operands. This is used for the PHI_iterator
/// in the SSAUpdaterImpl template.
namespace {