[PM] Add a utility pass template that synthesizes the invalidation of

a specific analysis result.

This is quite handy to test things, and will also likely be very useful
for debugging issues. You could narrow down pass validation failures by
walking these invalidate pass runs up and down the pass pipeline, etc.
I've added support to the pass pipeline parsing to be able to create one
of these for any analysis pass desired.

Just adding this class uncovered one latent bug where the
AnalysisManager CRTP base class had a hard-coded Module type rather than
using IRUnitT.

I've also added tests for invalidation and caching of analyses in
a basic way across all the pass managers. These in turn uncovered two
more bugs where we failed to correctly invalidate an analysis -- its
results were invalidated but the key for re-running the pass was never
cleared and so it was never re-run. Quite nasty. I'm very glad to debug
this here rather than with a full system.

Also, yes, the naming here is horrid. I'm going to update some of the
names to be slightly less awful shortly. But really, I've no "good"
ideas for naming. I'll be satisfied if I can get it to "not bad".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225246 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth
2015-01-06 04:49:44 +00:00
parent 7e6723e356
commit 17395fa733
5 changed files with 95 additions and 5 deletions

View File

@@ -105,7 +105,7 @@ void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
static bool isModulePassName(StringRef Name) {
#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
if (Name == "require<" NAME ">") \
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
return true;
#include "PassRegistry.def"
@@ -115,7 +115,7 @@ static bool isModulePassName(StringRef Name) {
static bool isCGSCCPassName(StringRef Name) {
#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
if (Name == "require<" NAME ">") \
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
return true;
#include "PassRegistry.def"
@@ -125,7 +125,7 @@ static bool isCGSCCPassName(StringRef Name) {
static bool isFunctionPassName(StringRef Name) {
#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
if (Name == "require<" NAME ">") \
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
return true;
#include "PassRegistry.def"
@@ -142,6 +142,10 @@ static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
if (Name == "require<" NAME ">") { \
MPM.addPass(NoopAnalysisRequirementPass<decltype(CREATE_PASS)>()); \
return true; \
} \
if (Name == "invalidate<" NAME ">") { \
MPM.addPass(NoopAnalysisInvalidationPass<decltype(CREATE_PASS)>()); \
return true; \
}
#include "PassRegistry.def"
@@ -158,6 +162,10 @@ static bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
if (Name == "require<" NAME ">") { \
CGPM.addPass(NoopAnalysisRequirementPass<decltype(CREATE_PASS)>()); \
return true; \
} \
if (Name == "invalidate<" NAME ">") { \
CGPM.addPass(NoopAnalysisInvalidationPass<decltype(CREATE_PASS)>()); \
return true; \
}
#include "PassRegistry.def"
@@ -174,6 +182,10 @@ static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
if (Name == "require<" NAME ">") { \
FPM.addPass(NoopAnalysisRequirementPass<decltype(CREATE_PASS)>()); \
return true; \
} \
if (Name == "invalidate<" NAME ">") { \
FPM.addPass(NoopAnalysisInvalidationPass<decltype(CREATE_PASS)>()); \
return true; \
}
#include "PassRegistry.def"