[PATCH] Refactor debug info lexical block generation

Paul Robinson Paul_Robinson at playstation.sony.com
Tue May 26 17:51:55 PDT 2015

Various inline comments.  Also, I don't understand the memory-management issues well enough to review collapseChild() properly; someone else will have to do that.


Comment at: lib/CodeGen/AsmPrinter/DwarfDebug.cpp:535
@@ +534,3 @@
+    if (auto *Skeleton = TheU->getSkeleton())
+      Dies.push_back(&Skeleton->getUnitDie());
+  }
I don't think skeleton DIEs can have lexical-block children?
If not, then collecting them is unnecessary work, which means you don't need to collect the Units into their own DIE vector.

Comment at: lib/CodeGen/AsmPrinter/DwarfDebug.cpp:544
@@ +543,3 @@
+    // parent instead, as this scope would serve no purpose.
+    bool Skip = Die->getAbbrev().getTag() == dwarf::DW_TAG_lexical_block;
+    for (auto &Child : Die->getChildren()) {
The 'for' loop collects CompileUnit DIEs, this loop iterates over the collected DIEs, therefore "Die" is a CompileUnit, which can't possibly have a lexical_block tag, therefore Skip is always false.
You need to traverse all the children of the Unit in order to find candidate lexical_blocks.

Comment at: lib/CodeGen/AsmPrinter/DwarfDebug.cpp:552
@@ +551,3 @@
+    if (Skip)
+      Die->getParent()->collapseChild(Die);
+  }
If my understanding is correct, then you could set a breakpoint here and never hit it.



More information about the llvm-commits mailing list