From 7a5a3f75eb6751c35682f506887c34bf57d6ea3e Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray <nicolas.geoffray@lip6.fr> Date: Sun, 31 Oct 2010 20:38:38 +0000 Subject: [PATCH] Attach a GCModuleInfo to a MachineFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117867 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineFunction.h | 6 +++++- lib/CodeGen/MachineFunction.cpp | 5 +++-- lib/CodeGen/MachineFunctionAnalysis.cpp | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 9347ae3cb36..f31c99a6f98 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -28,6 +28,7 @@ namespace llvm { class Value; class Function; +class GCModuleInfo; class MachineRegisterInfo; class MachineFrameInfo; class MachineConstantPool; @@ -75,6 +76,7 @@ class MachineFunction { const TargetMachine &Target; MCContext &Ctx; MachineModuleInfo &MMI; + GCModuleInfo *GMI; // RegInfo - Information about each register in use in the function. MachineRegisterInfo *RegInfo; @@ -127,10 +129,12 @@ class MachineFunction { void operator=(const MachineFunction&); // DO NOT IMPLEMENT public: MachineFunction(const Function *Fn, const TargetMachine &TM, - unsigned FunctionNum, MachineModuleInfo &MMI); + unsigned FunctionNum, MachineModuleInfo &MMI, + GCModuleInfo* GMI); ~MachineFunction(); MachineModuleInfo &getMMI() const { return MMI; } + GCModuleInfo *getGMI() const { return GMI; } MCContext &getContext() const { return Ctx; } /// getFunction - Return the LLVM function that this machine code represents diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 4a23d6e88de..e2c2bd5ed9e 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -52,8 +52,9 @@ void ilist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) { } MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM, - unsigned FunctionNum, MachineModuleInfo &mmi) - : Fn(F), Target(TM), Ctx(mmi.getContext()), MMI(mmi) { + unsigned FunctionNum, MachineModuleInfo &mmi, + GCModuleInfo* gmi) + : Fn(F), Target(TM), Ctx(mmi.getContext()), MMI(mmi), GMI(gmi) { if (TM.getRegisterInfo()) RegInfo = new (Allocator) MachineRegisterInfo(*TM.getRegisterInfo()); else diff --git a/lib/CodeGen/MachineFunctionAnalysis.cpp b/lib/CodeGen/MachineFunctionAnalysis.cpp index 4f84b952e06..3c10005b2d1 100644 --- a/lib/CodeGen/MachineFunctionAnalysis.cpp +++ b/lib/CodeGen/MachineFunctionAnalysis.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineFunctionAnalysis.h" +#include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" using namespace llvm; @@ -52,7 +53,8 @@ bool MachineFunctionAnalysis::doInitialization(Module &M) { bool MachineFunctionAnalysis::runOnFunction(Function &F) { assert(!MF && "MachineFunctionAnalysis already initialized!"); MF = new MachineFunction(&F, TM, NextFnNum++, - getAnalysis<MachineModuleInfo>()); + getAnalysis<MachineModuleInfo>(), + getAnalysisIfAvailable<GCModuleInfo>()); return false; }