aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-10 23:00:11 +0000
committerChris Lattner <sabre@nondot.org>2009-10-10 23:00:11 +0000
commitaf354a777f57a5585a3b210d785db6349539953f (patch)
tree09c2ccd55ead3c29507d192cd2bdbbeb6ab4607c /include
parent20c6ad636a273a51464d58d8f8bc1c56084e74af (diff)
downloadexternal_llvm-af354a777f57a5585a3b210d785db6349539953f.zip
external_llvm-af354a777f57a5585a3b210d785db6349539953f.tar.gz
external_llvm-af354a777f57a5585a3b210d785db6349539953f.tar.bz2
add the ability to get a rewritten value from the middle of a block,
not just at the end. Add a big comment explaining when this could be useful (which never happens for jump threading). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Transforms/Utils/SSAUpdater.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h
index 2897af9..8af50e3 100644
--- a/include/llvm/Transforms/Utils/SSAUpdater.h
+++ b/include/llvm/Transforms/Utils/SSAUpdater.h
@@ -48,16 +48,40 @@ public:
/// updates. ProtoValue is the value used to name PHI nodes.
void Initialize(Value *ProtoValue);
- /// AddAvailableValue - Indicate that a rewritten value is available in the
- /// specified block with the specified value.
+ /// AddAvailableValue - Indicate that a rewritten value is available at the
+ /// end of the specified block with the specified value.
void AddAvailableValue(BasicBlock *BB, Value *V);
/// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is
/// live at the end of the specified block.
Value *GetValueAtEndOfBlock(BasicBlock *BB);
+ /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that
+ /// is live in the middle of the specified block.
+ ///
+ /// GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one
+ /// important case: if there is a definition of the rewritten value after the
+ /// 'use' in BB. Consider code like this:
+ ///
+ /// X1 = ...
+ /// SomeBB:
+ /// use(X)
+ /// X2 = ...
+ /// br Cond, SomeBB, OutBB
+ ///
+ /// In this case, there are two values (X1 and X2) added to the AvailableVals
+ /// set by the client of the rewriter, and those values are both live out of
+ /// their respective blocks. However, the use of X happens in the *middle* of
+ /// a block. Because of this, we need to insert a new PHI node in SomeBB to
+ /// merge the appropriate values, and this value isn't live out of the block.
+ ///
+ Value *GetValueInMiddleOfBlock(BasicBlock *BB);
+
/// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes,
- /// which use their value in the corresponding predecessor.
+ /// which use their value in the corresponding predecessor. Note that this
+ /// will not work if the use is supposed to be rewritten to a value defined in
+ /// the same block as the use, but above it. Any 'AddAvailableValue's added
+ /// for the use's block will be considered to be below it.
void RewriteUse(Use &U);
private: