diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h --- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h +++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h @@ -49,6 +49,7 @@ class LLVMTargetMachine; class MMIAddrLabelMap; class MachineFunction; +class MachineFunctionAnalysisManager; class Module; //===----------------------------------------------------------------------===// @@ -304,6 +305,12 @@ MachineModuleInfo run(Module &M, ModuleAnalysisManager &); }; +struct FreeMachineFunctionPass : public PassInfoMixin { + PreservedAnalyses run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM); + static AnalysisKey Key; +}; + } // end namespace llvm #endif // LLVM_CODEGEN_MACHINEMODULEINFO_H diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachinePassManager.h" #include "llvm/CodeGen/Passes.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/DerivedTypes.h" @@ -300,6 +301,15 @@ return new FreeMachineFunction(); } +PreservedAnalyses +FreeMachineFunctionPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + MF.getMMI().deleteMachineFunctionFor(MF.getFunction()); + return PreservedAnalyses::all(); +} + +AnalysisKey FreeMachineFunctionPass::Key; + MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass( const LLVMTargetMachine *TM) : ImmutablePass(ID), MMI(TM) {