aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-19 18:22:18 +0000
committerDan Gohman <gohman@apple.com>2009-08-19 18:22:18 +0000
commite4af1cf4027d19cbe52d70858353dc1765ea3aef (patch)
tree97b50d3c1fb385078b36280b8084b9e073ef98dd /lib/Transforms
parent8255573835970e7130ba93271972172fb335f2ec (diff)
downloadexternal_llvm-e4af1cf4027d19cbe52d70858353dc1765ea3aef.zip
external_llvm-e4af1cf4027d19cbe52d70858353dc1765ea3aef.tar.gz
external_llvm-e4af1cf4027d19cbe52d70858353dc1765ea3aef.tar.bz2
Make SROA and PredicateSimplifier cope if TargetData is not
available. This is very conservative for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp10
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp12
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 4bcc339..2618336 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<DominatorTree>();
- AU.addRequired<TargetData>();
- AU.addPreserved<TargetData>();
}
private:
@@ -2409,7 +2407,13 @@ namespace {
bool PredicateSimplifier::runOnFunction(Function &F) {
DominatorTree *DT = &getAnalysis<DominatorTree>();
DTDFS = new DomTreeDFS(DT);
- TargetData *TD = &getAnalysis<TargetData>();
+ TargetData *TD = getAnalysisIfAvailable<TargetData>();
+
+ // 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 4f99ee8..378fb21 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<DominatorTree>();
AU.addRequired<DominanceFrontier>();
- AU.addRequired<TargetData>();
AU.setPreservesCFG();
}
@@ -150,9 +149,16 @@ FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) {
bool SROA::runOnFunction(Function &F) {
- TD = &getAnalysis<TargetData>();
-
+ TD = getAnalysisIfAvailable<TargetData>();
+
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