This is an archive of the discontinued LLVM Phabricator instance.

[DEBUGINFO] Disable emission of the dwarf sections, but allow directives.
ClosedPublic

Authored by ABataev on Apr 24 2018, 9:21 AM.

Details

Summary

Added an option that allows to emit only '.loc' and '.file' kind debug
directives, but disables emission of the DWARF sections. Required for
NVPTX target to support profiling. It requires '.loc' and '.file'
directives, but does not require any DWARF sections for the profiler.

Diff Detail

Event Timeline

ABataev created this revision.Apr 24 2018, 9:21 AM

Sorry, I'm a bit confused.

  1. I'd expect /this/ behavior (line table directives, but no debug_info, etc) to be controlled via a DICompileUnit emission kind (a value between "NoDebug" and "LineTablesOnly" as Paul mentioned).
  1. I'd expect the "no ', debug'" flag (which I don't see in this change? Is it missing? is it elsewhere?) to be controlled via an MCOption - because it must be global.

Now, arguably, if we have the global "no ', debug'" flag we maybe might as well use it to implement this behavior too since we don't have any other use for it? So maybe (2) invalidates (1).

Sorry, I'm a bit confused.

  1. I'd expect /this/ behavior (line table directives, but no debug_info, etc) to be controlled via a DICompileUnit emission kind (a value between "NoDebug" and "LineTablesOnly" as Paul mentioned).
  1. I'd expect the "no ', debug'" flag (which I don't see in this change? Is it missing? is it elsewhere?) to be controlled via an MCOption - because it must be global.

Now, arguably, if we have the global "no ', debug'" flag we maybe might as well use it to implement this behavior too since we don't have any other use for it? So maybe (2) invalidates (1).

I thought, that it is not very useful to have an option that, actually, controls only single target and I decided instead to add the option that just disables emission of the DWARF sections. In this case we don't need the special debug info mode, we can use this option.

ABataev updated this revision to Diff 157698.Jul 27 2018, 8:10 AM

Updated to latest version

Sorry, I'm a bit confused.

  1. I'd expect /this/ behavior (line table directives, but no debug_info, etc) to be controlled via a DICompileUnit emission kind (a value between "NoDebug" and "LineTablesOnly" as Paul mentioned).
  1. I'd expect the "no ', debug'" flag (which I don't see in this change? Is it missing? is it elsewhere?) to be controlled via an MCOption - because it must be global.

Now, arguably, if we have the global "no ', debug'" flag we maybe might as well use it to implement this behavior too since we don't have any other use for it? So maybe (2) invalidates (1).

I thought, that it is not very useful to have an option that, actually, controls only single target and I decided instead to add the option that just disables emission of the DWARF sections. In this case we don't need the special debug info mode, we can use this option.

I agree with Dave here. We already have some existing functionality that handles, for example, "minimal line tables" and so extending it to be "location directives only" seems like the direction we should go.

ABataev updated this revision to Diff 158571.Aug 1 2018, 10:42 AM

Reworked to control output by DICompileUnit emission kind.

dblaikie added inline comments.Aug 1 2018, 11:49 AM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2145

Could simplify this by dropping the "::const_iterator":

[](const decltype(CUMap)::value_type &Pair) {
test/DebugInfo/Generic/directives-only.ll
5

Is the integrated assembler tested here? Doesn't immediately look like it to me.

ABataev marked an inline comment as done.Aug 1 2018, 11:50 AM
ABataev added inline comments.
test/DebugInfo/Generic/directives-only.ll
5

Wrong comment, will remove it.

ABataev updated this revision to Diff 158597.Aug 1 2018, 12:03 PM

Address David's comments

dblaikie accepted this revision.Aug 1 2018, 12:12 PM
  • Naming of "DebugDirectivesOnly" could maybe be improved but I can't think of anything better - can be changed later if someone comes up with a better name in post-commit review
  • Probably add a helper function to DwarfCompileUnit to test if the CUNode specifies DebugDirectivesOnly ("bool DwarfCompileUnit::hasDebugDirectivesOnly()" for example) & use that everywhere, since this test is done in enough places and is a bit verbose as-is.
This revision is now accepted and ready to land.Aug 1 2018, 12:12 PM
This revision was automatically updated to reflect the committed changes.
tra added a subscriber: tra.Aug 15 2018, 9:59 AM

Is there a way to control this from clang command line?

In D46021#1200884, @tra wrote:

Is there a way to control this from clang command line?

Not yet, need to commit at least one more patch and then will start work on the clang patch for this feature.