diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-02-23 10:47:57 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-02-23 10:47:57 +0000 |
commit | c5d211ef2c5e50508da4b6309ff5f354d9e8f1f1 (patch) | |
tree | 229da1b60ce1bbbb6910c4f9efb5892b869e3fb0 /llvm/unittests/Analysis/CGSCCPassManagerTest.cpp | |
parent | 1eeac192269987150492b25b05e657311a73901b (diff) | |
download | bcm5719-llvm-c5d211ef2c5e50508da4b6309ff5f354d9e8f1f1.tar.gz bcm5719-llvm-c5d211ef2c5e50508da4b6309ff5f354d9e8f1f1.zip |
[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.
llvm-svn: 261627
Diffstat (limited to 'llvm/unittests/Analysis/CGSCCPassManagerTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/CGSCCPassManagerTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp index 49611d6dd3d..8d219e29844 100644 --- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -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); |