[llvm] [CodeGen] Make TargetRegisterInfo destructor public (NFC) (PR #157341)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 06:43:09 PDT 2025


https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/157341

All in-tree targets store target-specific TRI in target-specific Subtarget/InstrInfo class by value, but some downstream targets may prefer to store it as `std::unique_ptr<const TargetRegisterInfo>` (to avoid inclusion of MyTargetRegisterInfo.h in MySubtarget.h).

Making the destructor public makes this possible, and also follows general C++ guidelines (the destructor should be either public virtual or protected non-virtual).

All other related classes already have their destructors public.

>From ffec0de9c02efe75993a79fcbebce19bca2c0a4c Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Sun, 7 Sep 2025 16:42:04 +0300
Subject: [PATCH] [CodeGen] Make TargetRegisterInfo destructor public (NFC)

All in-tree targets store target-specific TRI in target-specific
Subtarget/InstrInfo class by value, but some downstream targets may
prefer to store it as `std::unique_ptr<const TargetRegisterInfo>`
(to avoid inclusion of MyTargetRegisterInfo.h in MySubtarget.h).

Making the destructor public makes this possible, and also follows
general C++ guidelines (the destructor should be either public virtual
or protected non-virtual).

All other related classes already have the destructor public.
---
 llvm/include/llvm/CodeGen/TargetRegisterInfo.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index 12ee51f130262..73ccc8ed5b11d 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -273,9 +273,10 @@ class LLVM_ABI TargetRegisterInfo : public MCRegisterInfo {
                      const RegClassInfo *const RCIs,
                      const MVT::SimpleValueType *const RCVTLists,
                      unsigned Mode = 0);
-  virtual ~TargetRegisterInfo();
 
 public:
+  virtual ~TargetRegisterInfo();
+
   /// Return the number of registers for the function. (may overestimate)
   virtual unsigned getNumSupportedRegs(const MachineFunction &) const {
     return getNumRegs();



More information about the llvm-commits mailing list