summaryrefslogtreecommitdiff
path: root/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
commit7eb28f3786543f63cb9a4099655e6d456fca71f7 (patch)
tree2ad6c36d847ad052f2b32e23765b21ecafdd1b1b /lib/Transforms/IPO/ArgumentPromotion.cpp
parentfa9ca0f788e96fe1eab506817b23d47eed1a3d36 (diff)
downloadllvm-7eb28f3786543f63cb9a4099655e6d456fca71f7.tar.gz
llvm-7eb28f3786543f63cb9a4099655e6d456fca71f7.tar.bz2
llvm-7eb28f3786543f63cb9a4099655e6d456fca71f7.tar.xz
Make TargetData optional in GlobalOpt and ArgumentPromotion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index e40372b04a..895a87b6ca 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/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!