[PATCH] D24223: [SelectionDAG] Add SDNode:RawSDNodeBits.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 09:15:34 PDT 2016


This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL281051: [SelectionDAG] Fix two issues with SDNode::getRawSubclassData(). (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24223?vs=70299&id=70849#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24223

Files:
  llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h

Index: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -463,14 +463,30 @@
   };
 
   union {
+    char RawSDNodeBits[sizeof(uint16_t)];
     SDNodeBitfields SDNodeBits;
     ConstantSDNodeBitfields ConstantSDNodeBits;
     MemSDNodeBitfields MemSDNodeBits;
     LSBaseSDNodeBitfields LSBaseSDNodeBits;
     LoadSDNodeBitfields LoadSDNodeBits;
     StoreSDNodeBitfields StoreSDNodeBits;
   };
 
+  // RawSDNodeBits must cover the entirety of the union.  This means that all
+  // of the union's members must have size <= RawSDNodeBits.
+  static_assert(sizeof(SDNodeBits) <= sizeof(RawSDNodeBits),
+                "SDNodeBits too wide");
+  static_assert(sizeof(ConstantSDNodeBits) <= sizeof(RawSDNodeBits),
+                "ConstantSDNodeBits too wide");
+  static_assert(sizeof(MemSDNodeBits) <= sizeof(RawSDNodeBits),
+                "MemSDNodeBits too wide");
+  static_assert(sizeof(LSBaseSDNodeBits) <= sizeof(RawSDNodeBits),
+                "LSBaseSDNodeBits too wide");
+  static_assert(sizeof(LoadSDNodeBits) <= sizeof(RawSDNodeBits),
+                "LoadSDNodeBits too wide");
+  static_assert(sizeof(StoreSDNodeBits) <= sizeof(RawSDNodeBits),
+                "StoreSDNodeBits too wide");
+
 private:
   /// Unique id per SDNode in the DAG.
   int NodeId;
@@ -876,7 +892,7 @@
       : NodeType(Opc), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs),
         UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), IROrder(Order),
         debugLoc(std::move(dl)) {
-    memset(&SDNodeBits, 0, sizeof(SDNodeBits));
+    memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits));
     assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
     assert(NumValues == VTs.NumVTs &&
            "NumValues wasn't wide enough for its operands!");
@@ -1095,9 +1111,7 @@
   /// function should only be used to compute a FoldingSetNodeID value.
   unsigned getRawSubclassData() const {
     uint16_t Data;
-    memcpy(&Data, &SDNodeBits, sizeof(SDNodeBits));
-    static_assert(sizeof(SDNodeBits) <= sizeof(uint16_t),
-                  "SDNodeBits field too large?");
+    memcpy(&Data, &RawSDNodeBits, sizeof(RawSDNodeBits));
     return Data;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24223.70849.patch
Type: text/x-patch
Size: 2362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160909/697b5d0c/attachment.bin>


More information about the llvm-commits mailing list