[PATCH] Refactor debug info lexical block generation

Paul Robinson Paul_Robinson at playstation.sony.com
Wed May 27 08:02:55 PDT 2015


> > I hope that makes sense...

> 

> 

> Kinda. Does that mean that we never kept nested scopes or are there more intricate conditions that makes us discard that particular nested scope? (I suppose the latter because otherwise we'd never generate any lexical scope)


If you have { { int x = 1; { foo(x);  } } } then there are 3 lexical blocks. We eliminate a lexical_block DIE if its immediate children consist solely of nested lexical_blocks and/or inlined_subroutines, so we actually emit DWARF that describes { int x = 1; foo(x); } which is semantically equivalent.  The current patch changes the timing of things so that, instead of not generating the lexical_blocks in the first place, we generate them up front and then decide to eliminate them later.

This is needed by the follow-up patch (which I think is the other half of http://reviews.llvm.org/D9758) so that if "x" is actually marked "static" then the correct lexical_block DIE will exist at the point where we know we want to attach "x" to it.


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);
+    }
+
----------------
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.

http://reviews.llvm.org/D9960

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






More information about the llvm-commits mailing list