[llvm] 6b94777 - [SystemZ] [NFC] Replace SpecialRegisters field with a unique_ptr instead of a raw pointer.

Fanbo Meng via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 08:28:23 PDT 2021


Author: Neumann Hon
Date: 2021-08-25T11:28:18-04:00
New Revision: 6b94777be5118377152eef8e4e21c4d0fe4e5bef

URL: https://github.com/llvm/llvm-project/commit/6b94777be5118377152eef8e4e21c4d0fe4e5bef
DIFF: https://github.com/llvm/llvm-project/commit/6b94777be5118377152eef8e4e21c4d0fe4e5bef.diff

LOG: [SystemZ] [NFC] Replace SpecialRegisters field with a unique_ptr instead of a raw pointer.

This patch replaces the SpecialRegisters field with a unique_ptr instead of a raw pointer. This is better practice, and allows us to remove the definition of the dtor for the SystemZSubtarget class.

Reviewed By: uweigand, Kai

Differential Revision: https://reviews.llvm.org/D108639

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
    llvm/lib/Target/SystemZ/SystemZSubtarget.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp b/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
index bfcdee270f292..13e54a603b1ba 100644
--- a/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
@@ -91,8 +91,6 @@ SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
       TSInfo(), FrameLowering() {}
 
-SystemZSubtarget::~SystemZSubtarget() { delete getSpecialRegisters(); }
-
 bool SystemZSubtarget::enableSubRegLiveness() const {
   return UseSubRegLiveness;
 }

diff  --git a/llvm/lib/Target/SystemZ/SystemZSubtarget.h b/llvm/lib/Target/SystemZ/SystemZSubtarget.h
index f6c155de44a00..4f7156add749c 100644
--- a/llvm/lib/Target/SystemZ/SystemZSubtarget.h
+++ b/llvm/lib/Target/SystemZ/SystemZSubtarget.h
@@ -77,7 +77,7 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
 
 private:
   Triple TargetTriple;
-  SystemZCallingConventionRegisters *SpecialRegisters;
+  std::unique_ptr<SystemZCallingConventionRegisters> SpecialRegisters;
   SystemZInstrInfo InstrInfo;
   SystemZTargetLowering TLInfo;
   SystemZSelectionDAGInfo TSInfo;
@@ -91,11 +91,9 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
   SystemZSubtarget(const Triple &TT, const std::string &CPU,
                    const std::string &FS, const TargetMachine &TM);
 
-  ~SystemZSubtarget();
-
   SystemZCallingConventionRegisters *getSpecialRegisters() const {
     assert(SpecialRegisters && "Unsupported SystemZ calling convention");
-    return SpecialRegisters;
+    return SpecialRegisters.get();
   }
 
   const TargetFrameLowering *getFrameLowering() const override {


        


More information about the llvm-commits mailing list