[PATCH] D92781: [NewPM][CodeGen] Port FreeMachineFunction to NPM

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 7 11:54:08 PST 2020


ychen created this revision.
ychen added a reviewer: aeubanks.
Herald added a subscriber: hiraditya.
ychen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92781

Files:
  llvm/include/llvm/CodeGen/MachineModuleInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp


Index: llvm/lib/CodeGen/MachineModuleInfo.cpp
===================================================================
--- llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ 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) {
Index: llvm/include/llvm/CodeGen/MachineModuleInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineModuleInfo.h
+++ 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<FreeMachineFunctionPass> {
+  PreservedAnalyses run(MachineFunction &MF,
+                        MachineFunctionAnalysisManager &MFAM);
+  static AnalysisKey Key;
+};
+
 } // end namespace llvm
 
 #endif // LLVM_CODEGEN_MACHINEMODULEINFO_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92781.309977.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201207/842c615f/attachment.bin>


More information about the llvm-commits mailing list