[PATCH] Refactor debug info lexical block generation

Frederic Riss friss at apple.com
Wed May 27 08:17:40 PDT 2015


In http://reviews.llvm.org/D9960#179348, @aaboud wrote:

> Lexical Blocks are collected only during function process, once we finish processing the function, all final lexical block DIEs are created but there is no map between the LLVM lexical block and the DIE lexical block.
>  This works just fine for nested lexical blocks and local variables.
>  However, it does not work with function static variables and types, such as typedef and records.


This is what I was missing. The current logic only works for local variables. Thanks.


REPOSITORY
  rL LLVM

================
Comment at: lib/CodeGen/AsmPrinter/DwarfDebug.cpp:545-549
@@ +544,7 @@
+    bool Skip = Die->getAbbrev().getTag() == dwarf::DW_TAG_lexical_block;
+    for (auto &Child : Die->getChildren()) {
+      Dies.push_back(&*Child);
+      Skip &= (Child->getAbbrev().getTag() == dwarf::DW_TAG_lexical_block ||
+               Child->getAbbrev().getTag() == dwarf::DW_TAG_inlined_subroutine);
+    }
+
----------------
probinson wrote:
> friss wrote:
> > This seems prohibitively expensive, you are adding each and every DIE in the tree to the worklist. I'm pretty sure you could filter to only take subprograms/blocks/inline_subroutines. (Even better, don't we already collect all the functions somewhere?)
> > 
> > This also seems wrong. You might remove inlined_subroutines with that change and we don't want that.
> I don't think this will remove inlined_subroutine DIEs; the intent here is that if a lexical_block contains (only) an inlined_subroutine, it's okay to eliminate the lexical_block, because the inlined_subroutine is its own scope.
Doh, you're right. Skip is set only if the current DIE is a lexical block. Still the way this is done seems very expensive. I bet the cost of that walk in noticeable in a RelWithDebugInfo build. Can we get some numbers?

http://reviews.llvm.org/D9960

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list