From 73996c5cb87e986913e5131f2efed69de3caf1c4 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 6 Jan 2015 20:05:02 +0000 Subject: [PATCH] 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. llvm-svn: 225292 --- llvm/include/llvm/CodeGen/MachineFunction.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 3271410..4e9ff9e 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/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); } -- 2.7.4