[PATCH] D26942: [SelectionDAG] getRawSubclassData should not return HasDebugValue.

Chih-Hung Hsieh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 12:17:25 PST 2016


chh added inline comments.


================
Comment at: include/llvm/CodeGen/SelectionDAGNodes.h:475-488
+  union AllSDNodeBitfields {
+    uint16_t Value;
     SDNodeBitfields SDNodeBits;
     ConstantSDNodeBitfields ConstantSDNodeBits;
     MemSDNodeBitfields MemSDNodeBits;
     LSBaseSDNodeBitfields LSBaseSDNodeBits;
     LoadSDNodeBitfields LoadSDNodeBits;
----------------
chandlerc wrote:
> This change seems a really big change and completely outside of the scope I suggested. I don't particularly like it (it seems to make things less clear) and I'm not sure what motivates it. Could you instead try the approach I suggested?
I thought this larger change would meet your previous suggestion to
"mirror the one in the class".

It hit me that the trouble in mirroring the structure was anonymous union,
and char array of RawSDNodeBits used just as uint16_t.
Giving the union a name and using "uint16_t Value" solved the problem
without memcpy.

Or, could you show me what to change the following version in my previous comment?


```
   unsigned getRawSubclassData() const {
     struct SDNodeBitsContainer {
       union {
         uint16_t Data;
         char RawSDNodeBits[sizeof(uint16_t)];
         SDNodeBitfields SDNodeBits;
       };
     } tmp;
     memcpy(&tmp.Data, &RawSDNodeBits, sizeof(RawSDNodeBits));
     tmp.SDNodeBits.HasDebugValue = 0;
     return tmp.Data;
   }

```


https://reviews.llvm.org/D26942





More information about the llvm-commits mailing list