diff options
author | Arthur Eubanks <aeubanks@google.com> | 2023-03-16 09:47:21 -0700 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2023-03-16 09:49:59 -0700 |
commit | 4c8ee1ac8221ef2d66b7f62b848a76d94196d87a (patch) | |
tree | f6ef17f4f809e2ff4445894be83935077a6e50c0 /llvm/lib/Transforms/Utils/Debugify.cpp | |
parent | 2be973e9d80b2680fc36ce7ed11461ffe3e6c7f5 (diff) | |
download | llvm-4c8ee1ac8221ef2d66b7f62b848a76d94196d87a.zip llvm-4c8ee1ac8221ef2d66b7f62b848a76d94196d87a.tar.gz llvm-4c8ee1ac8221ef2d66b7f62b848a76d94196d87a.tar.bz2 |
[Debugify] Use ModuleAnalysisManager in instrumentation
In preparation for doing module checks of PreservedAnalyses.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Debugify.cpp | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp index 5a310db..93cad08 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; |