This is an archive of the discontinued LLVM Phabricator instance.

[DWARFv5] Emit file 0 to the line table.
ClosedPublic

Authored by probinson on Mar 2 2018, 4:27 PM.

Details

Summary

DWARF v5 specifies that the root file (also given in the DW_AT_name attribute
of the compilation unit DIE) should be emitted explicitly to the line table's list of files.
This makes the line table more independent of the .debug_info section.

I am a bit nonplussed that more directory names are appearing in the .file directives now, which required more test changes than I expected, but I can't see that being harmful.

Diff Detail

Repository
rL LLVM

Event Timeline

probinson created this revision.Mar 2 2018, 4:27 PM
aprantl added inline comments.Mar 2 2018, 4:49 PM
llvm/lib/MC/MCAsmStreamer.cpp
1119 ↗(On Diff #136879)

That looks odd — is that a placeholder for later?

probinson added inline comments.Mar 2 2018, 5:01 PM
llvm/lib/MC/MCAsmStreamer.cpp
1119 ↗(On Diff #136879)

No, it's because asm output doesn't know how to distinguish multiple compile units in the line table. The corresponding MCStreamer (direct-to-object) method can handle different CUIDs.

aprantl accepted this revision.Mar 5 2018, 12:20 PM
aprantl added inline comments.
llvm/lib/MC/MCAsmStreamer.cpp
1119 ↗(On Diff #136879)

Perhaps add a && "not supported by MCAsmStreamer" for clarity?

This revision is now accepted and ready to land.Mar 5 2018, 12:20 PM
This revision was automatically updated to reflect the committed changes.
dstenb added a subscriber: dstenb.Mar 28 2018, 6:25 AM

With this change, we will emit the .file 0 directive even for -gdwarf-[234]. The directive results in an error when assembling with GAS. Should this be seen as a problem, or is it something that we accept?

In general, when using -gdwarf-[234], to what degree should clang/LLVM be compatible with assemblers and other tools that only partially support DWARFv5?

With this change, we will emit the .file 0 directive even for -gdwarf-[234]. The directive results in an error when assembling with GAS. Should this be seen as a problem, or is it something that we accept?

In general, when using -gdwarf-[234], to what degree should clang/LLVM be compatible with assemblers and other tools that only partially support DWARFv5?

You are correct, we should emit the '.file 0' directive and 'md5' clause only if we are producing DWARF v5. If we are producing DWARF v5 we require that the assembler be able to handle the extra information correctly.

I have somewhat arbitrarily picked syntax for supporting these v5 features. I don't know how to go about negotiating syntax with other assembler providers, or whether anyone else has started trying to produce standard DWARF v5 line tables. If anyone has advice I'd be pleased to hear it.
Probably llvm-dev would be a better forum than this code review.

Yeah, before committing to any new asm syntax, worth a conversation on
llvm-dev with the usual crew & hopefully we can rope in some folks from GCC
or whatnot. It might even be worth discussing on dwarf-discuss, even though
it's not technically a dwarf issue. (& if you're feeling up for it - if
we're having conversations about assembly syntax extensions anyway, there's
a couple of others that might be nice - the ability to specify a CU for
line table entries (LLVM can produce multiple line tables with its
integrated assembler, for use with LTO and ThinLTO, but falls back to
producing a single line table when producing textual assembly) - and maybe
one day the address pool stuff we've talked about)