[PATCH] D120714: [CodeGen] Place SDNode debug ID declaration under ifndef

Daniil Kovalev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 04:00:42 PST 2022


kovdan01 created this revision.
kovdan01 added reviewers: lattner, craig.topper, sunfish.
kovdan01 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Place `SDNode::PersistentId` and `SelectionDAG::NextPersistentId` declarations
under `#ifndef NDEBUG` so these fields are not declared in release builds as
they are only used for debug printing.

These ifndefs were deleted in df1ec5561a4a28a98ae3435878967875d19dd85e to keep
structure layout stable, but this does not look relevant anymore. SelectionDAG
class is not stable as it has NodeGraphAttrs field defined under ifndef NDEBUG.
Please let me know if there are some reasons to keep such members in release
builds, so I update the revision returning ifndefs and adding appropriate
comments not to confuse anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120714

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


Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
===================================================================
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -613,9 +613,11 @@
   SDNodeFlags Flags;
 
 public:
+#ifndef NDEBUG
   /// Unique and persistent id per SDNode in the DAG.
   /// Used for debug printing.
   uint16_t PersistentId;
+#endif
 
   //===--------------------------------------------------------------------===//
   //  Accessors
@@ -1216,9 +1218,11 @@
 public:
   explicit HandleSDNode(SDValue X)
     : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
+#ifndef NDEBUG
     // HandleSDNodes are never inserted into the DAG, so they won't be
     // auto-numbered. Use ID 65535 as a sentinel.
     PersistentId = 0xffff;
+#endif
 
     // Manually set up the operand list. This node type is special in that it's
     // always stack allocated and SelectionDAG does not manage its operands.
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
===================================================================
--- llvm/include/llvm/CodeGen/SelectionDAG.h
+++ llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -276,7 +276,10 @@
 
   DenseMap<const SDNode *, CallSiteDbgInfo> SDCallSiteDbgInfo;
 
+#ifndef NDEBUG
+  // Used for debug printing.
   uint16_t NextPersistentId = 0;
+#endif
 
 public:
   /// Clients of various APIs that cause global effects on


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120714.412039.patch
Type: text/x-patch
Size: 1445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/83c30d22/attachment.bin>


More information about the llvm-commits mailing list