"Ghostify" embedded sentinels. This is a real win in all cases
authorGabor Greif <ggreif@gmail.com>
Wed, 4 Mar 2009 06:57:48 +0000 (06:57 +0000)
committerGabor Greif <ggreif@gmail.com>
Wed, 4 Mar 2009 06:57:48 +0000 (06:57 +0000)
because less bytes are allocated and subobject construction is gone.
For reference how it works, see BasicBlock.h.
Btw. it is very assuring to see that somebody has invented
this ilist-embedded sentinel technique before me :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66026 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineFunction.h
include/llvm/CodeGen/SelectionDAG.h

index 54ac47008f231acd9a07ea296a6a1ddc11a24b27..5a9f3991f2c13f0ccba582ae7b87fe4edcbfe804 100644 (file)
@@ -26,14 +26,16 @@ class MachineFunction;
 template <>
 struct ilist_traits<MachineInstr> : public ilist_default_traits<MachineInstr> {
 private:
-  mutable MachineInstr Sentinel;
+  mutable ilist_node<MachineInstr> Sentinel;
 
   // this is only set by the MachineBasicBlock owning the LiveList
   friend class MachineBasicBlock;
   MachineBasicBlock* Parent;
 
 public:
-  MachineInstr *createSentinel() const { return &Sentinel; }
+  MachineInstr *createSentinel() const {
+    return static_cast<MachineInstr*>(&Sentinel);
+  }
   void destroySentinel(MachineInstr *) const {}
 
   void addNodeToList(MachineInstr* N);
index 689e4357b1d7819b3894946e12e466b84c6a6c95..1371f1d0cdf797014b52bba63a301e47ee54ec43 100644 (file)
@@ -37,9 +37,11 @@ class TargetMachine;
 template <>
 struct ilist_traits<MachineBasicBlock>
     : public ilist_default_traits<MachineBasicBlock> {
-  mutable MachineBasicBlock Sentinel;
+  mutable ilist_node<MachineBasicBlock> Sentinel;
 public:
-  MachineBasicBlock *createSentinel() const { return &Sentinel; }
+  MachineBasicBlock *createSentinel() const {
+    return static_cast<MachineBasicBlock*>(&Sentinel);
+  }
   void destroySentinel(MachineBasicBlock *) const {}
 
   void addNodeToList(MachineBasicBlock* MBB);
index 9ecba590dd417dae69f9096d06eaa724c41e0834..fe89fe0546018ad9845b56abca68b4f524761c98 100644 (file)
@@ -39,13 +39,10 @@ class FunctionLoweringInfo;
 
 template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
 private:
-  mutable SDNode Sentinel;
+  mutable ilist_node<SDNode> Sentinel;
 public:
-  ilist_traits() : Sentinel(ISD::DELETED_NODE, DebugLoc::getUnknownLoc(),
-                            SDVTList()) {}
-
   SDNode *createSentinel() const {
-    return &Sentinel;
+    return static_cast<SDNode*>(&Sentinel);
   }
   static void destroySentinel(SDNode *) {}