aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms
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
commit1a8d4de397c360a76f1389d15e862eba265d71fd (patch)
tree09c2ccd55ead3c29507d192cd2bdbbeb6ab4607c /include/llvm/Transforms
parent5fb107287fd8d35b8fc39aa3e6b084fb2871a8ff (diff)
downloadexternal_llvm-1a8d4de397c360a76f1389d15e862eba265d71fd.zip
external_llvm-1a8d4de397c360a76f1389d15e862eba265d71fd.tar.gz
external_llvm-1a8d4de397c360a76f1389d15e862eba265d71fd.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/llvm/Transforms')
-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: