[llvm] r261627 - [PM] Remove an overly aggressive assert now that I can actually test the

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 02:47:58 PST 2016


Author: chandlerc
Date: Tue Feb 23 04:47:57 2016
New Revision: 261627

URL: http://llvm.org/viewvc/llvm-project?rev=261627&view=rev
Log:
[PM] Remove an overly aggressive assert now that I can actually test the
pattern that triggers it. This essentially requires an immutable
function analysis, as that will survive anything we do to invalidate it.
When we have such patterns, the function analysis manager will not get
cleared between runs of the proxy.

If we actually need an assert about how things are queried, we can add
more elaborate machinery for computing it, but so far I'm not aware of
significant value provided.

Thanks to Justin Lebar for noticing this when he made a (seemingly
innocuous) change to FunctionAttrs that is enough to trigger it in one
test there. Now it is covered by a direct test of the pass manager code.

Modified:
    llvm/trunk/lib/Analysis/CGSCCPassManager.cpp
    llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp

Modified: llvm/trunk/lib/Analysis/CGSCCPassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CGSCCPassManager.cpp?rev=261627&r1=261626&r2=261627&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CGSCCPassManager.cpp (original)
+++ llvm/trunk/lib/Analysis/CGSCCPassManager.cpp Tue Feb 23 04:47:57 2016
@@ -50,7 +50,6 @@ char FunctionAnalysisManagerCGSCCProxy::
 
 FunctionAnalysisManagerCGSCCProxy::Result
 FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
-  assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!");
   return Result(*FAM);
 }
 

Modified: llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp?rev=261627&r1=261626&r2=261627&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp Tue Feb 23 04:47:57 2016
@@ -102,6 +102,30 @@ private:
 
 char TestFunctionAnalysis::PassID;
 
+class TestImmutableFunctionAnalysis {
+public:
+  struct Result {
+    bool invalidate(Function &, const PreservedAnalyses &) { return false; }
+  };
+
+  static void *ID() { return (void *)&PassID; }
+  static StringRef name() { return "TestImmutableFunctionAnalysis"; }
+
+  TestImmutableFunctionAnalysis(int &Runs) : Runs(Runs) {}
+
+  Result run(Function &F, FunctionAnalysisManager *AM) {
+    ++Runs;
+    return Result();
+  }
+
+private:
+  static char PassID;
+
+  int &Runs;
+};
+
+char TestImmutableFunctionAnalysis::PassID;
+
 struct TestModulePass {
   TestModulePass(int &RunCount) : RunCount(RunCount) {}
 
@@ -155,6 +179,9 @@ struct TestSCCPass {
         TestFunctionAnalysis::Result &FAR =
             FAM.getResult<TestFunctionAnalysis>(N.getFunction());
         AnalyzedInstrCount += FAR.InstructionCount;
+
+        // Just ensure we get the immutable results.
+        (void)FAM.getResult<TestImmutableFunctionAnalysis>(N.getFunction());
       }
     }
 
@@ -234,6 +261,10 @@ TEST_F(CGSCCPassManagerTest, Basic) {
   FunctionAnalysisManager FAM(/*DebugLogging*/ true);
   int FunctionAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
+  int ImmutableFunctionAnalysisRuns = 0;
+  FAM.registerPass([&] {
+    return TestImmutableFunctionAnalysis(ImmutableFunctionAnalysisRuns);
+  });
 
   CGSCCAnalysisManager CGAM(/*DebugLogging*/ true);
   int SCCAnalysisRuns = 0;
@@ -277,6 +308,7 @@ TEST_F(CGSCCPassManagerTest, Basic) {
   EXPECT_EQ(1, ModuleAnalysisRuns);
   EXPECT_EQ(4, SCCAnalysisRuns);
   EXPECT_EQ(6, FunctionAnalysisRuns);
+  EXPECT_EQ(6, ImmutableFunctionAnalysisRuns);
 
   EXPECT_EQ(4, SCCPassRunCount1);
   EXPECT_EQ(14, AnalyzedInstrCount1);




More information about the llvm-commits mailing list