This is an archive of the discontinued LLVM Phabricator instance.

Emit discriminator for inlined callsites.
ClosedPublic

Authored by danielcdh on Nov 9 2015, 1:08 PM.

Details

Summary

Inlined callsites need to be emitted in debug info so that sample profile can be annotated to the correct inlined instance.

Diff Detail

Event Timeline

danielcdh updated this revision to Diff 39742.Nov 9 2015, 1:08 PM
danielcdh retitled this revision from to Emit discriminator for inlined callsites..
danielcdh updated this object.
danielcdh added reviewers: dnovillo, dblaikie.
danielcdh added a subscriber: llvm-commits.
dblaikie added inline comments.Nov 9 2015, 1:15 PM
test/DebugInfo/Generic/discriminator.ll
11

perhaps write these with attribute((always_inline)) so you can build the example without running the full optimization pipeline & still get the desired code.

Do you need two different inline functions or two different destination functions? (maybe it makes the example simpler/more obvious, which is fair - but it could just be two of the same)

14

I assume this function doesn't need a parameter

dblaikie edited edge metadata.Nov 9 2015, 1:25 PM
dblaikie added a subscriber: dblaikie.

btw, there's no need to file a bug as you're providing a fix - feel free to
skip the overhead and just provide the patch & skip the bug

The only real reason to file a bug in the open source tracker is if you
want someone else to look at/work on it/know you are working on it before
you've sent out a patch, etc.

danielcdh updated this revision to Diff 39745.Nov 9 2015, 1:29 PM
danielcdh edited edge metadata.

Simplify the testcase.

It gives a warning:
a.cc:2:34: warning: GCC does not allow 'always_inline' attribute in this position on a function definition [-Wgcc-compat]

FYI, the debug info size impact for this change: clang-3.8 binary (built by clang itself in release mode with -g) increases from 1117.1MB to 1118.7MB (0.14% increase)

dnovillo edited edge metadata.Nov 10 2015, 3:24 PM

The one thing I don't understand about this patch is why it needs to add a new DW_*discriminator flag? But I don't know enough DWARF to decide whether using the existing flag is OK or not.

Also, this is a final codegen issue? That is, the actual AddDiscriminators pass is DTRT?

dblaikie accepted this revision.Nov 11 2015, 9:39 AM
dblaikie edited edge metadata.

Couple of minor fixes/improvements, but looks right enough - commit when ready.

lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
442

Drop {} around a single-line block (the idiomatic/prevailing style in the LLVM project, though I don't think we have it written in the style guide)

test/DebugInfo/Generic/discriminator.ll
11

Switch the attribute earlier and you can do this without the separate declaration:

static void __attribute__((always_inline)) bar() { xyz(); }
16

CHECK could be a bit more detailed - I'm guessing the first inlined subroutine doesn't need a discriminator, and the second does? Something like:

CHECK: DW_TAG_inlined_subroutine
CHECK-NOT: DW_AT_discriminator
CHECK: DW_TAG_inlined_subroutine
CHECK-NOT: {{DW_TAG|NULL}}
CHECK: DW_AT_discriminator 1
This revision is now accepted and ready to land.Nov 11 2015, 9:39 AM
danielcdh closed this revision.Nov 11 2015, 10:10 AM