[PATCH] D120714: [CodeGen] Use SDNode debug ID declaration in release builds

Daniil Kovalev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 13 04:55:10 PDT 2022


kovdan01 updated this revision to Diff 414926.
kovdan01 retitled this revision from "[CodeGen] Place SDNode debug ID declaration under ifndef" to "[CodeGen] Use SDNode debug ID declaration in release builds".
kovdan01 edited the summary of this revision.
kovdan01 added a comment.
Herald added a subscriber: hiraditya.

@dexonsmith Thanks for your comments! Decided to choose the last approach that you mentioned - keep and use `PersistentId` regardless build type or any macro. The problem with `#if LLVM_ENABLE_ABI_BREAKING_CHECKS` is testing with `LLVM_ABI_BREAKING_CHECKS` set to `FORCE_OFF` during initial CMake configuration - some tests rely on PersistentId. I suppose that having PersistentId present in all builds is definitely worth small CPU overhead compared to the current state.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120714/new/

https://reviews.llvm.org/D120714

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
@@ -81,11 +81,7 @@
                                               const SelectionDAG *Graph) {
       std::string R;
       raw_string_ostream OS(R);
-#ifndef NDEBUG
       OS << 't' << Node->PersistentId;
-#else
-      OS << static_cast<const void *>(Node);
-#endif
       return R;
     }
 
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -505,11 +505,7 @@
 
 static Printable PrintNodeId(const SDNode &Node) {
   return Printable([&Node](raw_ostream &OS) {
-#ifndef NDEBUG
     OS << 't' << Node.PersistentId;
-#else
-    OS << (const void*)&Node;
-#endif
   });
 }
 
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1036,8 +1036,8 @@
 /// verification and other common operations when a new node is allocated.
 void SelectionDAG::InsertNode(SDNode *N) {
   AllNodes.push_back(N);
-#ifndef NDEBUG
   N->PersistentId = NextPersistentId++;
+#ifndef NDEBUG
   VerifySDNode(N);
 #endif
   for (DAGUpdateListener *DUL = UpdateListeners; DUL; DUL = DUL->Next)
@@ -1241,9 +1241,7 @@
   AllNodes.remove(AllNodes.begin());
   while (!AllNodes.empty())
     DeallocateNode(&AllNodes.front());
-#ifndef NDEBUG
   NextPersistentId = 0;
-#endif
 }
 
 SDNode *SelectionDAG::FindNodeOrInsertPos(const FoldingSetNodeID &ID,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120714.414926.patch
Type: text/x-patch
Size: 1832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220313/81cc9570/attachment.bin>


More information about the llvm-commits mailing list