[PATCH] D36627: dwarfdump: Add an option to collect debug info quality metrics

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 11:10:54 PDT 2017


rnk added a comment.

You probably want to rebase this to pick up https://reviews.llvm.org/rL312042.



================
Comment at: tools/llvm-dwarfdump/Statistics.cpp:64
+  auto &Stats = Statistics[Prefix];
+  Stats.VarsInFunction.insert({Name, 0});
+  if (BytesInScope) {
----------------
aprantl wrote:
> dblaikie wrote:
> > Name wouldn't be unambiguous - due to shadowing?
> Yes, this doesn't handle 
> ```
> void f() {
>   { int i = 1; }
>   { int i = 2; }
> }
> ```
> correctly right now, and I'm also not quite sure how to fix this right now. We could give all lexical scopes unique names based on their nesting levels, but if there are two inlined instances of the same function:
> 
> ```
> void f(bool b) {
>   if (b) {
>     int i = 1;
>   } else {
>     int i = 2;
>   }
> }
> ```
> 
> one inlined as `f(true)`, and one as `f(false)` with only one lexical block remaining in each inlined instance, I don't know how to handle that.
Numbering the scopes reminds me of what MSVC does for name mangling static locals. I don't think it's terribly important to worry about local variable shadowing in the first iteration of this. I suspect it mostly comes up for induction variables (`I` and `E`).


https://reviews.llvm.org/D36627





More information about the llvm-commits mailing list