diff options
author | Owen Anderson <resistor@mac.com> | 2008-12-14 19:10:35 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-12-14 19:10:35 +0000 |
commit | cbe1d940313a0e7d75820f2c92a6c089fbc15f5a (patch) | |
tree | 91b97f93070bb07b2b8eb4d0b5a10f32b34db569 /lib | |
parent | b6862bbe34be4a832f709596f8dc971ab9895b06 (diff) | |
download | external_llvm-cbe1d940313a0e7d75820f2c92a6c089fbc15f5a.zip external_llvm-cbe1d940313a0e7d75820f2c92a6c089fbc15f5a.tar.gz external_llvm-cbe1d940313a0e7d75820f2c92a6c089fbc15f5a.tar.bz2 |
Generalize GVN's phi construciton routine to work for things other than loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 2081811..5e5e8b7 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -728,7 +728,7 @@ namespace { bool processNonLocalLoad(LoadInst* L, SmallVectorImpl<Instruction*> &toErase); bool processBlock(DomTreeNode* DTN); - Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, + Value *GetValueForBlock(BasicBlock *BB, Instruction* orig, DenseMap<BasicBlock*, Value*> &Phis, bool top_level = false); void dump(DenseMap<uint32_t, Value*>& d); @@ -789,7 +789,7 @@ bool GVN::isSafeReplacement(PHINode* p, Instruction* inst) { /// GetValueForBlock - Get the value to use within the specified basic block. /// available values are in Phis. -Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, +Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig, DenseMap<BasicBlock*, Value*> &Phis, bool top_level) { @@ -837,7 +837,11 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, Value* v = CollapsePhi(PN); if (!v) { // Cache our phi construction results - phiMap[orig->getPointerOperand()].insert(PN); + if (LoadInst* L = dyn_cast<LoadInst>(orig)) + phiMap[L->getPointerOperand()].insert(PN); + else + phiMap[orig].insert(PN); + return PN; } |