aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms/Utils/SSAUpdater.h
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-04-17 03:08:24 +0000
committerBob Wilson <bob.wilson@apple.com>2010-04-17 03:08:24 +0000
commit84bd6b0c31f41cdd1d859dab54b6bc1177c4c6bb (patch)
treebf31667194458144634432af4f95bd8b3f088c1c /include/llvm/Transforms/Utils/SSAUpdater.h
parent8295d4c96c8530acb7ae0098d813b53dc4fe0a89 (diff)
downloadexternal_llvm-84bd6b0c31f41cdd1d859dab54b6bc1177c4c6bb.zip
external_llvm-84bd6b0c31f41cdd1d859dab54b6bc1177c4c6bb.tar.gz
external_llvm-84bd6b0c31f41cdd1d859dab54b6bc1177c4c6bb.tar.bz2
Re-commit my previous SSAUpdater changes. The previous version naively tried
to determine where to place PHIs by iteratively comparing reaching definitions at each block. That was just plain wrong. This version now computes the dominator tree within the subset of the CFG where PHIs may need to be placed, and then places the PHIs in the iterated dominance frontier of each definition. The rest of the patch is mostly the same, with a few more performance improvements added in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/SSAUpdater.h')
-rw-r--r--include/llvm/Transforms/Utils/SSAUpdater.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h
index 927e156..5b77ed6 100644
--- a/include/llvm/Transforms/Utils/SSAUpdater.h
+++ b/include/llvm/Transforms/Utils/SSAUpdater.h
@@ -21,28 +21,31 @@ namespace llvm {
class PHINode;
template<typename T>
class SmallVectorImpl;
+ class BumpPtrAllocator;
/// SSAUpdater - This class updates SSA form for a set of values defined in
/// multiple blocks. This is used when code duplication or another unstructured
/// transformation wants to rewrite a set of uses of one value with uses of a
/// set of values.
class SSAUpdater {
+public:
+ class BBInfo;
+ typedef SmallVectorImpl<BBInfo*> BlockListTy;
+
+private:
/// AvailableVals - This keeps track of which value to use on a per-block
- /// basis. When we insert PHI nodes, we keep track of them here. We use
- /// TrackingVH's for the value of the map because we RAUW PHI nodes when we
- /// eliminate them, and want the TrackingVH's to track this.
- //typedef DenseMap<BasicBlock*, TrackingVH<Value> > AvailableValsTy;
+ /// basis. When we insert PHI nodes, we keep track of them here.
+ //typedef DenseMap<BasicBlock*, Value*> AvailableValsTy;
void *AV;
/// PrototypeValue is an arbitrary representative value, which we derive names
/// and a type for PHI nodes.
Value *PrototypeValue;
- /// IncomingPredInfo - We use this as scratch space when doing our recursive
- /// walk. This should only be used in GetValueInBlockInternal, normally it
- /// should be empty.
- //std::vector<std::pair<BasicBlock*, TrackingVH<Value> > > IncomingPredInfo;
- void *IPI;
+ /// BBMap - The GetValueAtEndOfBlock method maintains this mapping from
+ /// basic blocks to BBInfo structures.
+ /// typedef DenseMap<BasicBlock*, BBInfo*> BBMapTy;
+ void *BM;
/// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that
/// it creates to the vector.
@@ -99,6 +102,15 @@ public:
private:
Value *GetValueAtEndOfBlockInternal(BasicBlock *BB);
+ void BuildBlockList(BasicBlock *BB, BlockListTy *BlockList,
+ BumpPtrAllocator *Allocator);
+ void FindDominators(BlockListTy *BlockList);
+ void FindPHIPlacement(BlockListTy *BlockList);
+ void FindAvailableVals(BlockListTy *BlockList);
+ void FindExistingPHI(BasicBlock *BB, BlockListTy *BlockList);
+ bool CheckIfPHIMatches(PHINode *PHI);
+ void RecordMatchingPHI(PHINode *PHI);
+
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT
};