diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 4bcc339464a..26183365a6a 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -2284,8 +2284,6 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequiredID(BreakCriticalEdgesID); AU.addRequired(); - AU.addRequired(); - AU.addPreserved(); } private: @@ -2409,7 +2407,13 @@ namespace { bool PredicateSimplifier::runOnFunction(Function &F) { DominatorTree *DT = &getAnalysis(); DTDFS = new DomTreeDFS(DT); - TargetData *TD = &getAnalysis(); + TargetData *TD = getAnalysisIfAvailable(); + + // FIXME: PredicateSimplifier should still be able to do basic + // optimizations without TargetData. But for now, just exit if + // it's not available. + if (!TD) return false; + Context = &F.getContext(); DEBUG(errs() << "Entering Function: " << F.getName() << "\n"); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 4f99ee8e6ef..378fb21a466 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -68,7 +68,6 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); - AU.addRequired(); AU.setPreservesCFG(); } @@ -150,9 +149,16 @@ FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) { bool SROA::runOnFunction(Function &F) { - TD = &getAnalysis(); - + TD = getAnalysisIfAvailable(); + bool Changed = performPromotion(F); + + // FIXME: ScalarRepl currently depends on TargetData more than it + // theoretically needs to. It should be refactored in order to support + // target-independent IR. Until this is done, just skip the actual + // scalar-replacement portion of this pass. + if (!TD) return Changed; + while (1) { bool LocalChange = performScalarRepl(F); if (!LocalChange) break; // No need to repromote if no scalarrepl