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

Neumann Hon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 09:23:23 PDT 2021


Everybody0523 created this revision.
Everybody0523 added reviewers: uweigand, Kai, anirudhp.
Herald added a subscriber: hiraditya.
Everybody0523 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108639

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


Index: llvm/lib/Target/SystemZ/SystemZSubtarget.h
===================================================================
--- llvm/lib/Target/SystemZ/SystemZSubtarget.h
+++ llvm/lib/Target/SystemZ/SystemZSubtarget.h
@@ -77,7 +77,7 @@
 
 private:
   Triple TargetTriple;
-  SystemZCallingConventionRegisters *SpecialRegisters;
+  std::unique_ptr<SystemZCallingConventionRegisters> SpecialRegisters;
   SystemZInstrInfo InstrInfo;
   SystemZTargetLowering TLInfo;
   SystemZSelectionDAGInfo TSInfo;
@@ -91,11 +91,9 @@
   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 {
Index: llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
+++ llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
@@ -91,8 +91,6 @@
       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
       TSInfo(), FrameLowering() {}
 
-SystemZSubtarget::~SystemZSubtarget() { delete getSpecialRegisters(); }
-
 bool SystemZSubtarget::enableSubRegLiveness() const {
   return UseSubRegLiveness;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108639.368370.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210824/7276b4f1/attachment.bin>


More information about the llvm-commits mailing list