There are cases where a concrete DIE with DW_TAG_subprogram can have abstract_origin attribute, so we handle that situation as well.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–465 | "IsPotentialAbstractOrigin"? | |
464–471 | This name and the associated names (InlineFnsToBeProcessed, etc) may be incorrect now? (or it looks like, if we're tracking "InlinedVars" Separately, perhaps this variable is the wrong one for tracking those - yeah, judging by the statistics that have changed - we probably shouldn't be grouping these non-inline concrete definitions under the "#inlined functions" or "#inlined functions with abstract origins" (also not sure why we have those two different statistics - inlined functions without abstract origins are non-DWARF-conforming, I think) |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–465 | Does this stand for the lines 465,466? (I guess it does) | |
464–471 | Hmmm.... I am a bit confused. :) If we have a concrete DW_TAG_subprogram with an abstract_origin (representing e.g. an always_inline function), are we counting it as an inlined function or as a concrete one? If it is a concrete function, we should rename InlineFnsToBeProcessed, etc. |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 | I believe we should be counting it as a concrete one - are we not? Looks like we are counting them as concrete. Given this example: __attribute__((nodebug)) void f1(); void f2() { f1(); } void f3() { f2(); } (compiled with -O3 to force the inlining, or use attributes to do the same) 0x0000000b: DW_TAG_compile_unit DW_AT_name ("test.cpp") 0x0000002a: DW_TAG_subprogram DW_AT_abstract_origin (0x0000003d "_Z2f2v") 0x0000003d: DW_TAG_subprogram DW_AT_name ("f2") 0x00000049: DW_TAG_subprogram DW_AT_name ("f3") 0x00000062: DW_TAG_inlined_subroutine DW_AT_abstract_origin (0x0000003d "_Z2f2v") The relevant stats are: "#functions": 2, "#functions with location": 2, "#inlined functions": 1, "#inlined functions with abstract origins": 1, (I don't know why we have a separate stat for #inlined functions compared to #inlined functions with abstract origins - pretty sure the latter should just be a verifier error (& not one I'd expect to be common either) rather than a statistic) So the two functions should me f2 and f3 (0x0000002a and 0x00000049, but not 0x0000003d). |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
Actually yes.
Hmmm, I agree, there is no point of having inlined_subroutine with no abstract_origin, right?
|
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
Sorry, bit confused by this answer. "Yes we are counting out of line definitions of inline functions as concrete" or "Yes we are not counting out of line definitions of inline functions as concrete"...
I mean, DWARF supports it syntactically, but I don't think it's supported semantically - because the DW_TAG_inlined_subroutine is in the location of the inlining, not in the location the function is defined. So it needs to use an abstract_origin (& the spec says it does /have/ to do this, I Think) to point to a DW_TAG_subprogram that's in the scope where the function was written by the programmer. Might be worth roping in whoevre implemented these statistics to check what the thinking was behind them? |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
Sorry for the confusion. Yes, we are counting these as concrete functions.
My understanding of this goes in the same direction.
The patch that has introduced this is D58849. |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
I think we can check it -- should we do that via llvm-dev mailing list? |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
OK, so to unwind the conversational stack, we are correctly counting non-inline subprograms that have abstract origins as concrete (not inline) and we should name the variable the same - Ah, which I see you've done. Maybe the right name would be "XxxxWithAbstractOrigin" as "AbstractOriginXxx" sounds like they are the abstract origins (the thing abstract_origin points to) rather than the thing that refers to an abstract origin?
Yep, sounds good to me - cc/include me and the patch authors/reviewers (@cmtice and @aprantl). |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
464–471 |
Oh yes...it makes sense to me! Thanks! I'll update the change in order to differentiate these two cases. |
Sorry, I know this is annoying - but could you commit the renaming as a separate preliminary patch (feel free to commit that without review)? It'd make it much easier to understand the semantic change in this patch with that separated.
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
230–231 | Side note: why are we passing around std::strings by value? Should these be being passed by const ref? |
(Sorry for delay, I was on PTO.)
It makes sense to me, I'll do that ASAP.
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
230–231 | I think we should be using const ref instead. |
Looks good, thanks!
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
230–231 | oh, sure - easier to see this is untouched now that the renaming is separated, thanks! | |
461–462 | maybe more accurately named HasAbstractOrigin? (IsPotentialAbstractOrigin sounds like this DIE /is/ the one referenced by an abstract_origin, rather than being the DIE with the abstract_origin) |
llvm/tools/llvm-dwarfdump/Statistics.cpp | ||
---|---|---|
230–231 | Yep! |
Side note: why are we passing around std::strings by value? Should these be being passed by const ref?