summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-14 00:11:03 +0000
committerDan Gohman <gohman@apple.com>2009-08-14 00:11:03 +0000
commitdbeb33936f24837bbaddf74d0a086705afd8f7e4 (patch)
tree0326bc89983cecba106a224f4e004475ae8335f3 /llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
parent3e9dbe5a100d791819dc4d0825b650805c887840 (diff)
downloadbcm5719-llvm-dbeb33936f24837bbaddf74d0a086705afd8f7e4.tar.gz
bcm5719-llvm-dbeb33936f24837bbaddf74d0a086705afd8f7e4.zip
Make TargetData optional in GlobalOpt and ArgumentPromotion.
llvm-svn: 78967
Diffstat (limited to 'llvm/lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index e40372b04a1..895a87b6cad 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -61,7 +61,6 @@ namespace {
struct VISIBILITY_HIDDEN ArgPromotion : public CallGraphSCCPass {
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AliasAnalysis>();
- AU.addRequired<TargetData>();
CallGraphSCCPass::getAnalysisUsage(AU);
}
@@ -433,7 +432,8 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg, bool isByVal) const {
SmallPtrSet<BasicBlock*, 16> TranspBlocks;
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
- TargetData &TD = getAnalysis<TargetData>();
+ TargetData *TD = getAnalysisIfAvailable<TargetData>();
+ if (!TD) return false; // Without TargetData, assume the worst.
for (unsigned i = 0, e = Loads.size(); i != e; ++i) {
// Check to see if the load is invalidated from the start of the block to
@@ -443,7 +443,7 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg, bool isByVal) const {
const PointerType *LoadTy =
cast<PointerType>(Load->getPointerOperand()->getType());
- unsigned LoadSize = (unsigned)TD.getTypeStoreSize(LoadTy->getElementType());
+ unsigned LoadSize =(unsigned)TD->getTypeStoreSize(LoadTy->getElementType());
if (AA.canInstructionRangeModify(BB->front(), *Load, Arg, LoadSize))
return false; // Pointer is invalidated!
OpenPOWER on IntegriCloud