diff options
| author | Dale Johannesen <dalej@apple.com> | 2009-05-14 18:41:18 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2009-05-14 18:41:18 +0000 |
| commit | 1ac1969e09e43b3ea2f0545ac035a46c4bc09afa (patch) | |
| tree | 878001e5281043e23f105a962efc2edd4dc3f5d5 /llvm/lib/Transforms | |
| parent | 6ddc11aeddff03ad803099ac4754cdfa03f2753e (diff) | |
| download | bcm5719-llvm-1ac1969e09e43b3ea2f0545ac035a46c4bc09afa.tar.gz bcm5719-llvm-1ac1969e09e43b3ea2f0545ac035a46c4bc09afa.zip | |
Reuse existing getUnderlyingObject instead of
adding another copy.
llvm-svn: 71783
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 79b92eaabe0..2cde765560b 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -348,21 +348,6 @@ static Value *GetIfCondition(BasicBlock *BB, return 0; } -/// findGlobalVariableBase - Recurse into a ConstantExpr to find the underlying -/// GlobalVariable, if there is one. -static GlobalVariable* findGlobalVariableBase(ConstantExpr* CE) { - if (isa<GlobalVariable>(CE)) - return dyn_cast<GlobalVariable>(CE); - if (CE->getOpcode()==Instruction::GetElementPtr || - CE->getOpcode()==Instruction::BitCast) { - if (isa<GlobalVariable>(CE->getOperand(0))) - return dyn_cast<GlobalVariable>(CE->getOperand(0)); - if (ConstantExpr *CE2 = dyn_cast<ConstantExpr>(CE->getOperand(0))) - return findGlobalVariableBase(CE2); - } - return NULL; -} - /// DominatesMergePoint - If we have a merge point of an "if condition" as /// accepted above, return true if the specified value dominates the block. We /// don't handle the true generality of domination here, just a special case @@ -409,15 +394,12 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB, !isa<Constant>(I->getOperand(0))) return false; // External weak globals may have address 0, so we can't load them. - GlobalVariable* GV = dyn_cast<GlobalVariable>(I->getOperand(0)); - if (GV && GV->hasExternalWeakLinkage()) - return false; - // The global may be buried within a ConstantExpr. - if (ConstantExpr *CE = dyn_cast<ConstantExpr>(I->getOperand(0))) - GV = findGlobalVariableBase(CE); - if (GV && GV->hasExternalWeakLinkage()) - return false; - + Value *V2 = I->getOperand(0)->getUnderlyingObject(); + if (V2) { + GlobalVariable* GV = dyn_cast<GlobalVariable>(V2); + if (GV && GV->hasExternalWeakLinkage()) + return false; + } // Finally, we have to check to make sure there are no instructions // before the load in its basic block, as we are going to hoist the loop // out to its predecessor. |

