This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Suppress .loc directives coming from CFI instructions
ClosedPublic

Authored by probinson on Dec 6 2016, 4:45 PM.

Details

Summary

CFI pseudo-instructions emit nothing to the .text section, therefore there's no reason to emit their source locations into the line table.
In practice, a CFI instruction's source location will be one of three things: (a) exactly the same as the preceding instruction; (b) exactly the same as the following instruction; (c) unspecified. The first two cases have no net effect on the line table. The third case will emit a "line 0" record whenever we turn unspecified locations into "line 0" which can happen with -use-unknown-locations or, after the patch in D24180 lands (again), if the CFI instruction happens to be at the top of a basic block. This patch causes the third case to have no net effect on the line table, just like the other cases.

Diff Detail

Repository
rL LLVM

Event Timeline

probinson updated this revision to Diff 80503.Dec 6 2016, 4:45 PM
probinson retitled this revision from to [DWARF] Suppress .loc directives coming from CFI instructions.
probinson updated this object.
probinson added reviewers: dblaikie, aprantl.
probinson added subscribers: llvm-commits, kcc.
aprantl accepted this revision.Dec 8 2016, 9:13 AM
aprantl edited edge metadata.

Seems reasonable.

test/DebugInfo/Generic/no-cfi-loc.ll
2 ↗(On Diff #80503)

Short comment on what is being checked here?
And is there anything positive that could be checked for, too? Tests that only CHECK-NOT love to break without anybody noticing :-)

This revision is now accepted and ready to land.Dec 8 2016, 9:13 AM
probinson added inline comments.Dec 8 2016, 4:02 PM
test/DebugInfo/Generic/no-cfi-loc.ll
2 ↗(On Diff #80503)

It ends up emitting a CFI instruction with no debug location. The test is verifying that this does not result in a line-0 record (that we skip the CFI instruction).

Although, I now realize the fact that there is a CFI instruction at all is not obvious! Maybe I should turn this into an MIR test instead.

aprantl added inline comments.Dec 9 2016, 8:33 AM
test/DebugInfo/Generic/no-cfi-loc.ll
2 ↗(On Diff #80503)

My main point was that a test like this would work even if you symlink llc to /usr/bin/true. I would suggest to at least check for the function label and one other .loc directive that is expected to be in the output.

This revision was automatically updated to reflect the committed changes.
probinson added inline comments.Dec 9 2016, 12:48 PM
test/DebugInfo/Generic/no-cfi-loc.ll
2 ↗(On Diff #80503)

Sorry, didn't see this before I committed. The new test does look for the .cfi directive, and verifies that no line-0 directive appears before that.
I could add more positive checks if you think that would be more robust.