[llvm] 4c8ee1a - [Debugify] Use ModuleAnalysisManager in instrumentation
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 09:50:08 PDT 2023
Author: Arthur Eubanks
Date: 2023-03-16T09:49:59-07:00
New Revision: 4c8ee1ac8221ef2d66b7f62b848a76d94196d87a
URL: https://github.com/llvm/llvm-project/commit/4c8ee1ac8221ef2d66b7f62b848a76d94196d87a
DIFF: https://github.com/llvm/llvm-project/commit/4c8ee1ac8221ef2d66b7f62b848a76d94196d87a.diff
LOG: [Debugify] Use ModuleAnalysisManager in instrumentation
In preparation for doing module checks of PreservedAnalyses.
Added:
Modified:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Utils/Debugify.h
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/tools/opt/NewPMDriver.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 485eb3ad2ab8..95da681eb3bc 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -857,7 +857,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!CodeGenOpts.DIBugsReportFilePath.empty())
Debugify.setOrigDIVerifyBugsReportFilePath(
CodeGenOpts.DIBugsReportFilePath);
- Debugify.registerCallbacks(PIC, FAM);
+ Debugify.registerCallbacks(PIC, MAM);
}
// Attempt to load pass plugins and register their callbacks with PB.
for (auto &PluginFN : CodeGenOpts.PassPlugins) {
diff --git a/llvm/include/llvm/Transforms/Utils/Debugify.h b/llvm/include/llvm/Transforms/Utils/Debugify.h
index 795768037da7..d4440942a64e 100644
--- a/llvm/include/llvm/Transforms/Utils/Debugify.h
+++ b/llvm/include/llvm/Transforms/Utils/Debugify.h
@@ -193,7 +193,7 @@ class DebugifyEachInstrumentation {
public:
void registerCallbacks(PassInstrumentationCallbacks &PIC,
- FunctionAnalysisManager &FAM);
+ ModuleAnalysisManager &MAM);
// Used within DebugifyMode::SyntheticDebugInfo mode.
void setDIStatsMap(DebugifyStatsMap &StatMap) { DIStatsMap = &StatMap; }
const DebugifyStatsMap &getDebugifyStatsMap() const { return *DIStatsMap; }
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 5a310db1c164..93cad0888a56 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -1029,51 +1029,58 @@ static bool isIgnoredPass(StringRef PassID) {
}
void DebugifyEachInstrumentation::registerCallbacks(
- PassInstrumentationCallbacks &PIC, FunctionAnalysisManager &FAM) {
- PIC.registerBeforeNonSkippedPassCallback([this, &FAM](StringRef P, Any IR) {
+ PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM) {
+ PIC.registerBeforeNonSkippedPassCallback([this, &MAM](StringRef P, Any IR) {
if (isIgnoredPass(P))
return;
PreservedAnalyses PA;
PA.preserveSet<CFGAnalyses>();
- if (const auto **F = any_cast<const Function *>(&IR)) {
- applyDebugify(*const_cast<Function *>(*F),
- Mode, DebugInfoBeforePass, P);
- FAM.invalidate(*const_cast<Function *>(*F), PA);
- } else if (const auto **M = any_cast<const Module *>(&IR)) {
- applyDebugify(*const_cast<Module *>(*M),
- Mode, DebugInfoBeforePass, P);
- for (Function &F : *const_cast<Module *>(*M))
- FAM.invalidate(F, PA);
- }
- });
- PIC.registerAfterPassCallback([this](StringRef P, Any IR,
- const PreservedAnalyses &PassPA) {
- if (isIgnoredPass(P))
- return;
if (const auto **CF = any_cast<const Function *>(&IR)) {
- auto &F = *const_cast<Function *>(*CF);
- Module &M = *F.getParent();
- auto It = F.getIterator();
- if (Mode == DebugifyMode::SyntheticDebugInfo)
- checkDebugifyMetadata(M, make_range(It, std::next(It)), P,
- "CheckFunctionDebugify", /*Strip=*/true, DIStatsMap);
- else
- checkDebugInfoMetadata(
- M, make_range(It, std::next(It)), *DebugInfoBeforePass,
- "CheckModuleDebugify (original debuginfo)",
- P, OrigDIVerifyBugsReportFilePath);
+ Function &F = *const_cast<Function *>(*CF);
+ applyDebugify(F, Mode, DebugInfoBeforePass, P);
+ MAM.getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
+ .getManager()
+ .invalidate(F, PA);
} else if (const auto **CM = any_cast<const Module *>(&IR)) {
- auto &M = *const_cast<Module *>(*CM);
- if (Mode == DebugifyMode::SyntheticDebugInfo)
- checkDebugifyMetadata(M, M.functions(), P, "CheckModuleDebugify",
- /*Strip=*/true, DIStatsMap);
- else
- checkDebugInfoMetadata(
- M, M.functions(), *DebugInfoBeforePass,
- "CheckModuleDebugify (original debuginfo)",
- P, OrigDIVerifyBugsReportFilePath);
+ Module &M = *const_cast<Module *>(*CM);
+ applyDebugify(M, Mode, DebugInfoBeforePass, P);
+ MAM.invalidate(M, PA);
}
});
+ PIC.registerAfterPassCallback(
+ [this, &MAM](StringRef P, Any IR, const PreservedAnalyses &PassPA) {
+ if (isIgnoredPass(P))
+ return;
+ PreservedAnalyses PA;
+ PA.preserveSet<CFGAnalyses>();
+ if (const auto **CF = any_cast<const Function *>(&IR)) {
+ auto &F = *const_cast<Function *>(*CF);
+ Module &M = *F.getParent();
+ auto It = F.getIterator();
+ if (Mode == DebugifyMode::SyntheticDebugInfo)
+ checkDebugifyMetadata(M, make_range(It, std::next(It)), P,
+ "CheckFunctionDebugify", /*Strip=*/true,
+ DIStatsMap);
+ else
+ checkDebugInfoMetadata(M, make_range(It, std::next(It)),
+ *DebugInfoBeforePass,
+ "CheckModuleDebugify (original debuginfo)",
+ P, OrigDIVerifyBugsReportFilePath);
+ MAM.getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
+ .getManager()
+ .invalidate(F, PA);
+ } else if (const auto **CM = any_cast<const Module *>(&IR)) {
+ Module &M = *const_cast<Module *>(*CM);
+ if (Mode == DebugifyMode::SyntheticDebugInfo)
+ checkDebugifyMetadata(M, M.functions(), P, "CheckModuleDebugify",
+ /*Strip=*/true, DIStatsMap);
+ else
+ checkDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
+ "CheckModuleDebugify (original debuginfo)",
+ P, OrigDIVerifyBugsReportFilePath);
+ MAM.invalidate(M, PA);
+ }
+ });
}
char DebugifyModulePass::ID = 0;
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index bcf6a7f3f9aa..57d3d2e86aa3 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -402,13 +402,13 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
if (DebugifyEach) {
Debugify.setDIStatsMap(DIStatsMap);
Debugify.setDebugifyMode(DebugifyMode::SyntheticDebugInfo);
- Debugify.registerCallbacks(PIC, FAM);
+ Debugify.registerCallbacks(PIC, MAM);
} else if (VerifyEachDebugInfoPreserve) {
Debugify.setDebugInfoBeforePass(DebugInfoBeforePass);
Debugify.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
Debugify.setOrigDIVerifyBugsReportFilePath(
VerifyDIPreserveExport);
- Debugify.registerCallbacks(PIC, FAM);
+ Debugify.registerCallbacks(PIC, MAM);
}
PipelineTuningOptions PTO;
More information about the llvm-commits
mailing list