Index: include/llvm/CodeGen/RegAllocRegistry.h =================================================================== --- include/llvm/CodeGen/RegAllocRegistry.h +++ include/llvm/CodeGen/RegAllocRegistry.h @@ -23,29 +23,30 @@ //===----------------------------------------------------------------------===// /// -/// RegisterRegAlloc class - Track the registration of register allocators. +/// RegisterRegAllocBase class - Track the registration of register allocators. /// //===----------------------------------------------------------------------===// -class RegisterRegAlloc : public MachinePassRegistryNode { +template +class RegisterRegAllocBase : public MachinePassRegistryNode { public: using FunctionPassCtor = FunctionPass *(*)(); static MachinePassRegistry Registry; - RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C) + RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C) : MachinePassRegistryNode(N, D, C) { Registry.Add(this); } - ~RegisterRegAlloc() { Registry.Remove(this); } + ~RegisterRegAllocBase() { Registry.Remove(this); } // Accessors. - RegisterRegAlloc *getNext() const { - return (RegisterRegAlloc *)MachinePassRegistryNode::getNext(); + SubClass *getNext() const { + return static_cast(MachinePassRegistryNode::getNext()); } - static RegisterRegAlloc *getList() { - return (RegisterRegAlloc *)Registry.getList(); + static SubClass *getList() { + return static_cast(Registry.getList()); } static FunctionPassCtor getDefault() { return Registry.getDefault(); } @@ -57,6 +58,17 @@ } }; +class RegisterRegAlloc : public RegisterRegAllocBase { +public: + RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C) + : RegisterRegAllocBase(N, D, C) {} +}; + +/// RegisterRegAlloc's global Registry tracks allocator registration. +template +MachinePassRegistry +RegisterRegAllocBase::Registry; + } // end namespace llvm #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H Index: lib/CodeGen/TargetPassConfig.cpp =================================================================== --- lib/CodeGen/TargetPassConfig.cpp +++ lib/CodeGen/TargetPassConfig.cpp @@ -1028,10 +1028,6 @@ llvm_unreachable("Invalid optimize-regalloc state"); } -/// RegisterRegAlloc's global Registry tracks allocator registration. -MachinePassRegistry - RegisterRegAlloc::Registry; - /// A dummy default pass factory indicates whether the register allocator is /// overridden on the command line. static llvm::once_flag InitializeDefaultRegisterAllocatorFlag;