From bb531c9a0068a078c5bbe95298769b235aa1ad75 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 7 Feb 2024 10:15:43 -0700 Subject: [NewPM/Codegen] Move MachineModuleInfo ownership outside of analysis (#80937) With the legacy pass manager, MachineModuleInfoWrapperPass owned the MachineModuleInfo used in the codegen pipeline. It can do this since it's an ImmutablePass that doesn't get invalidated. However, with the new pass manager, it is legal for the ModuleAnalysisManager to clear all of its analyses, regardless of if the analysis does not want to be invalidated. So we must move ownership of the MachineModuleInfo outside of the analysis (this is similar to PassInstrumentation). For now, make the PassBuilder user register a MachineModuleAnalysis that returns a reference to a MachineModuleInfo that the user owns. Perhaps we can find a better place to own the MachineModuleInfo to make using the codegen pass manager less cumbersome in the future. --- llvm/lib/CodeGen/MachineModuleInfo.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp') diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 921feb2..f24288b 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -237,11 +237,10 @@ bool MachineModuleInfoWrapperPass::doFinalization(Module &M) { AnalysisKey MachineModuleAnalysis::Key; -MachineModuleInfo MachineModuleAnalysis::run(Module &M, - ModuleAnalysisManager &) { - MachineModuleInfo MMI(TM); +MachineModuleAnalysis::Result +MachineModuleAnalysis::run(Module &M, ModuleAnalysisManager &) { MMI.TheModule = &M; - MMI.DbgInfoAvailable = !DisableDebugInfoPrinting && - !M.debug_compile_units().empty(); - return MMI; + MMI.DbgInfoAvailable = + !DisableDebugInfoPrinting && !M.debug_compile_units().empty(); + return Result(MMI); } -- cgit v1.1