summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
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
commitc3fb03e289a5b1122ea98073ba3714f171bfbb0c (patch)
treed8f60d9e55d005f6ad254b11130e6025f5bea5a7 /llvm/lib/Transforms/Utils
parentb50407f104fa2986bd3c40c1ab2fc082aff65a7f (diff)
downloadbcm5719-llvm-c3fb03e289a5b1122ea98073ba3714f171bfbb0c.tar.gz
bcm5719-llvm-c3fb03e289a5b1122ea98073ba3714f171bfbb0c.zip
implement SSAUpdater::RewriteUseAfterInsertions, a helpful form of RewriteUse.
llvm-svn: 112409
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/SSAUpdater.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp
index f4bdb527655..9dc2a1ed38e 100644
--- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp
+++ b/llvm/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 {
OpenPOWER on IntegriCloud