aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Debugify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Debugify.cpp83
1 files changed, 49 insertions, 34 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 989473693a0b..93cad0888a56 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -979,7 +979,9 @@ PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
"ModuleDebugify (original debuginfo)",
NameOfWrappedPass);
- return PreservedAnalyses::all();
+ PreservedAnalyses PA;
+ PA.preserveSet<CFGAnalyses>();
+ return PA;
}
ModulePass *createCheckDebugifyModulePass(
@@ -1027,45 +1029,58 @@ static bool isIgnoredPass(StringRef PassID) {
}
void DebugifyEachInstrumentation::registerCallbacks(
- PassInstrumentationCallbacks &PIC) {
- PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, Any IR) {
- if (isIgnoredPass(P))
- return;
- if (const auto **F = any_cast<const Function *>(&IR))
- applyDebugify(*const_cast<Function *>(*F),
- Mode, DebugInfoBeforePass, P);
- else if (const auto **M = any_cast<const Module *>(&IR))
- applyDebugify(*const_cast<Module *>(*M),
- Mode, DebugInfoBeforePass, P);
- });
- PIC.registerAfterPassCallback([this](StringRef P, Any IR,
- const PreservedAnalyses &PassPA) {
+ PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM) {
+ PIC.registerBeforeNonSkippedPassCallback([this, &MAM](StringRef P, Any IR) {
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);
+ 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;