[DebugInfo] Generate debug information for labels.
ClosedPublic

Authored by HsiangKai on Mar 29 2018, 7:35 AM.

Details

Summary

Generate DILabel metadata and call llvm.dbg.label after label statement to associate the metadata with the label. This patch should be reviewed with D45024.

Diff Detail

Repository
rL LLVM
HsiangKai created this revision.Mar 29 2018, 7:35 AM
HsiangKai changed the repository for this revision from rL LLVM to rC Clang.Mar 29 2018, 7:35 AM
chenwj requested changes to this revision.Mar 30 2018, 6:23 AM

Nits.

lib/CodeGen/CGDebugInfo.cpp
3644 ↗(On Diff #140248)

Indent.

lib/CodeGen/CGStmt.cpp
535 ↗(On Diff #140248)

I assume you emit debug info for the label only if it's reachable by checking HaveInsertPoint(). If so, make the comment as

// Emit debug info for the label only if it's reachable.

I prefer adding braces here. Please check indent as well.

This revision now requires changes to proceed.Mar 30 2018, 6:23 AM
HsiangKai updated this revision to Diff 140423.Mar 30 2018, 7:19 AM
HsiangKai retitled this revision from [DebugInfo] Generate debug information about labels to [DebugInfo] Generate DILabel metadata for labels..
HsiangKai edited the summary of this revision. (Show Details)
  1. No generating llvm.dbg.label intrinsic.
  2. Modify commits according to chenwj's comments.
HsiangKai updated this revision to Diff 140627.Apr 2 2018, 8:14 AM
HsiangKai retitled this revision from [DebugInfo] Generate DILabel metadata for labels. to [DebugInfo] Generate debug information for labels..
HsiangKai edited the summary of this revision. (Show Details)
HsiangKai updated this revision to Diff 141989.Apr 11 2018, 6:12 AM

Update the test case for inlined functions. The inlined label will attach to DISubprogram(..., labels: !n)

One question, but otherwise this looks fine.

lib/CodeGen/CGStmt.cpp
535 ↗(On Diff #141989)

Shouldn't it be added to the list of labels/variables of the DISubprogram regardless?

HsiangKai updated this revision to Diff 142533.Apr 14 2018, 7:02 PM

Update test cases.

HsiangKai marked 2 inline comments as done.Apr 16 2018, 8:00 AM

Always add labels to DISubprogram even unreachable.

aprantl accepted this revision.Apr 16 2018, 9:09 AM

Please run your changes through clang format before checking this in; otherwise LGTM.

  • Update test cases.
  • Checked with clang-format.
HsiangKai marked an inline comment as done.Apr 26 2018, 11:21 PM

@chenwj Do you have any comments for this patch?

This revision was not accepted when it landed; it landed in state Needs Review.May 8 2018, 7:47 PM
Closed by commit rL331843: [DebugInfo] Generate debug information for labels. (authored by shiva, committed by ). · Explain Why
This revision was automatically updated to reflect the committed changes.
hans added a subscriber: hans.May 9 2018, 2:33 AM

This broke the Chromium build. I've uploaded a reproducer at https://bugs.chromium.org/p/chromium/issues/detail?id=841170#c1

I'm guessing maybe a Clang bootstrap with debug info might also reproduce the problem, but I haven't tried that.

Reverted in r331861.

This broke the Chromium build. I've uploaded a reproducer at https://bugs.chromium.org/p/chromium/issues/detail?id=841170#c1

I'm guessing maybe a Clang bootstrap with debug info might also reproduce the problem, but I haven't tried that.

Reverted in r331861.

https://reviews.llvm.org/D46738 should fix the bug.

This broke the Chromium build. I've uploaded a reproducer at https://bugs.chromium.org/p/chromium/issues/detail?id=841170#c1

I'm guessing maybe a Clang bootstrap with debug info might also reproduce the problem, but I haven't tried that.

Reverted in r331861.

https://reviews.llvm.org/D46738 should fix the bug.

rL336176 has fixed the bug. Could I revert the commit?
You could refer to PR37395.

hans added a comment.Tue, Jul 3, 2:38 AM

This broke the Chromium build. I've uploaded a reproducer at https://bugs.chromium.org/p/chromium/issues/detail?id=841170#c1

I'm guessing maybe a Clang bootstrap with debug info might also reproduce the problem, but I haven't tried that.

Reverted in r331861.

https://reviews.llvm.org/D46738 should fix the bug.

rL336176 has fixed the bug. Could I revert the commit?
You could refer to PR37395.

I'm not familiar with your patch, but if you're confident that it works (for example, a clang bootstrap works), then committing again sounds good to me.