From: Mehdi Amini Date: Tue, 6 Jan 2015 20:05:02 +0000 (+0000) Subject: Use a Factory Method for MachineFunctionInfo Creation X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=193f586fd2c40a040e3b058add9cc36dc862534c;p=oota-llvm.git Use a Factory Method for MachineFunctionInfo Creation The goal is to allows MachineFunctionInfo to override this create function to customize the creation. No change intended in existing backend in this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225292 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 3271410d71b..4e9ff9ebb4f 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -72,6 +72,15 @@ private: /// MachineFunction is destroyed. struct MachineFunctionInfo { virtual ~MachineFunctionInfo(); + + /// \brief Factory function: default behavior is to call new using the + /// supplied allocator. + /// + /// This function can be overridden in a derive class. + template + static Ty *create(BumpPtrAllocator &Allocator, MachineFunction &MF) { + return new (Allocator.Allocate()) Ty(MF); + } }; class MachineFunction { @@ -239,7 +248,7 @@ public: template Ty *getInfo() { if (!MFInfo) - MFInfo = new (Allocator.Allocate()) Ty(*this); + MFInfo = Ty::template create(Allocator, *this); return static_cast(MFInfo); }