[llvm-commits] [PATCH 3/3] Implement requiredTransitive
Tobias Grosser
grosser at fim.uni-passau.de
Fri Sep 3 07:53:55 PDT 2010
The PassManager did not implement the transitivity of requiredTransitive. We
just did not notice.
---
lib/VMCore/PassManager.cpp | 14 +++++++++++
.../2010-09-03-RequiredTransitive.ll | 24 ++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
create mode 100644 test/Analysis/ScalarEvolution/2010-09-03-RequiredTransitive.ll
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index ab4d4e5..2a491d0 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -507,6 +507,20 @@ void PMTopLevelManager::setLastUser(SmallVector<Pass *, 12> &AnalysisPasses,
if (P == AP)
continue;
+ // Update the last users of passes that are required transitive by AP.
+ AnalysisUsage *AnUsage = findAnalysisUsage(AP);
+ const AnalysisUsage::VectorType &IDs = AnUsage->getRequiredTransitiveSet();
+ SmallVector<Pass *, 12> LastUses;
+ for (AnalysisUsage::VectorType::const_iterator I = IDs.begin(),
+ E = IDs.end(); I != E; ++I) {
+ if (Pass *AnalysisPass = findAnalysisPass(*I))
+ LastUses.push_back(AnalysisPass);
+ else
+ llvm_unreachable("There is a problem");
+ }
+
+ setLastUser(LastUses, P);
+
// If AP is the last user of other passes then make P last user of
// such passes.
for (DenseMap<Pass *, Pass *>::iterator LUI = LastUser.begin(),
diff --git a/test/Analysis/ScalarEvolution/2010-09-03-RequiredTransitive.ll b/test/Analysis/ScalarEvolution/2010-09-03-RequiredTransitive.ll
new file mode 100644
index 0000000..88f1338
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2010-09-03-RequiredTransitive.ll
@@ -0,0 +1,24 @@
+; RUN: opt -indvars -scalar-evolution -disable-output -analyze
+; This test checks if the SCEV analysis is printed out at all.
+; It failed once as the RequiredTransitive option was not implemented
+; correctly.
+
+define i32 @main() nounwind {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ] ; <i64> [#uses=3]
+ %exitcond = icmp ne i64 %indvar1, 1024 ; <i1> [#uses=1]
+ br i1 %exitcond, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %indvar.next2 = add i64 %indvar1, 1 ; <i64> [#uses=1]
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret i32 0
+}
--
1.7.1
More information about the llvm-commits
mailing list