[DebugInfo] Generate debug information for labels.
Needs ReviewPublic

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

Details

Reviewers
rnk
chenwj
aprantl
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
rC Clang
HsiangKai created this revision.Thu, Mar 29, 7:35 AM
HsiangKai changed the repository for this revision from rL LLVM to rC Clang.Thu, Mar 29, 7:35 AM
chenwj requested changes to this revision.Fri, Mar 30, 6:23 AM

Nits.

lib/CodeGen/CGDebugInfo.cpp
3644

Indent.

lib/CodeGen/CGStmt.cpp
535

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.Fri, Mar 30, 6:23 AM
HsiangKai updated this revision to Diff 140423.Fri, Mar 30, 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.Mon, Apr 2, 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.Wed, Apr 11, 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

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

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

Update test cases.

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

Always add labels to DISubprogram even unreachable.

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

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

  • Update test cases.
  • Checked with clang-format.