Make TargetData optional in GlobalOpt and ArgumentPromotion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78967 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-08-14 00:11:03 +00:00
parent fa9ca0f788
commit 7eb28f3786
2 changed files with 16 additions and 15 deletions

View File

@@ -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!