This is an archive of the discontinued LLVM Phabricator instance.

Prevent DW_AT_abstract_origin from being emitted twice for the same subprogram
ClosedPublic

Authored by aprantl on May 9 2016, 9:22 AM.

Details

Reviewers
dblaikie
aaboud
Summary

This fixes a bug where DW_AT_abstract_origin is being emitted twice for the same subprogram if a function is both inlined and emitted in the same translation unit, by restoring the pre-r266446 behavior.

Diff Detail

Event Timeline

aprantl updated this revision to Diff 56588.May 9 2016, 9:22 AM
aprantl retitled this revision from to Prevent DW_AT_abstract_origin from being emitted twice for the same subprogram.
aprantl updated this object.
aprantl added reviewers: aaboud, dblaikie.
aprantl added a subscriber: llvm-commits.
dblaikie added inline comments.May 9 2016, 11:56 AM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
525

Do we need the extra data structure? How did this code work before the CU<>Subprogram inversion?

test/DebugInfo/X86/abstract_origin.ll
3

Simplify the test case - remove the parameters and return value and use attribute((alwaysinline)) (I never remember how to spell that attribute name..)

Should be simple enough to just use:

void f1();
__attribute__((alwaysinline)) void f2() {
  f1();
}
void f3() {
  f2();
}

Even at -O0 it should produce the same/desired code (an inlined function and a non-inline version).

5

Unintentional blank line here?

aprantl updated this revision to Diff 56648.May 9 2016, 3:42 PM
aprantl updated this object.
aprantl added inline comments.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
525

Ok, this is a really good question. There is no evidence for this code existing prior to the CU<>Subprogram inversion and the test suite still passes after removing it.

aprantl updated this object.May 9 2016, 3:43 PM
aprantl marked 4 inline comments as done.
aaboud accepted this revision.May 10 2016, 1:45 AM
aaboud edited edge metadata.

LGTM.
You may commit once you fix the test as David suggested and use the attribute((always_inline)).

Regards,
Amjad

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
525

This change seems to be correct.
Inline (DW_TAG_inlined_subroutine) and abstract (DW_TAG_subprogram) entries are filled once they are created.
The only entry that is filled when it is finalizing (finishing) subprograms is the concrete (DW_TAG_subprogram) entry, and this entry exists only if there is code generated for it.
So, the first loop is enough to handle this entry.

This revision is now accepted and ready to land.May 10 2016, 1:45 AM
aprantl closed this revision.May 10 2016, 12:47 PM

thanks! r269103.