[llvm-commits] [llvm] r79442 - in /llvm/trunk/lib/Transforms/Scalar: PredicateSimplifier.cpp ScalarReplAggregates.cpp
Dan Gohman
gohman at apple.com
Wed Aug 19 11:22:18 PDT 2009
Author: djg
Date: Wed Aug 19 13:22:18 2009
New Revision: 79442
URL: http://llvm.org/viewvc/llvm-project?rev=79442&view=rev
Log:
Make SROA and PredicateSimplifier cope if TargetData is not
available. This is very conservative for now.
Modified:
llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp?rev=79442&r1=79441&r2=79442&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp Wed Aug 19 13:22:18 2009
@@ -2284,8 +2284,6 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(BreakCriticalEdgesID);
AU.addRequired<DominatorTree>();
- AU.addRequired<TargetData>();
- AU.addPreserved<TargetData>();
}
private:
@@ -2409,7 +2407,13 @@
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");
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=79442&r1=79441&r2=79442&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Wed Aug 19 13:22:18 2009
@@ -68,7 +68,6 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<DominatorTree>();
AU.addRequired<DominanceFrontier>();
- AU.addRequired<TargetData>();
AU.setPreservesCFG();
}
@@ -150,9 +149,16 @@
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
More information about the llvm-commits
mailing list