[PATCH] D135166: [DebugInfo] getMergedLocation: Maintain the line number if they match

Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 09:23:13 PDT 2022


jmmartinez created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
jmmartinez edited the summary of this revision.
jmmartinez retitled this revision from "[DebugInfo] getMergedLocation: Maintain the line number if they match" to "[Draft][DebugInfo] getMergedLocation: Maintain the line number if they match".
jmmartinez added reviewers: probinson, dblaikie.
jmmartinez added a project: debug-info.
jmmartinez retitled this revision from "[Draft][DebugInfo] getMergedLocation: Maintain the line number if they match" to "[DebugInfo] getMergedLocation: Maintain the line number if they match".
jmmartinez edited the summary of this revision.
jmmartinez edited the summary of this revision.
jmmartinez edited the summary of this revision.
jmmartinez edited the summary of this revision.
jmmartinez edited the summary of this revision.
jmmartinez updated this revision to Diff 465043.
jmmartinez added a comment.
jmmartinez published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Remove from drafts


getMergedLocation returns a 'line 0' DILocaiton if the two locations
being merged don't perfecly match, even if they are in the same line but
a different column.

This commit adds support to keep the line number if it matches (but only
the column differs). The merged column number is the leftmost between the
two.

For comparison,

- the GCC output: https://godbolt.org/z/4Mqxfa983
- the Clang output: https://godbolt.org/z/zWaT14Yqr

Notice that gcc seems to use the location of "a" in both cases, while Clang return a line 0 location even if both locations are on the same line.

Should Clang give the correct line number but with column 0? or the left-most? or the line 0 location is in fact more accurate? And should it use the inlined-at scope+line+column in the case it matches?

I have yet to read the source-code of gcc to understand exactly how it works.

Any advice on the subject is welcomed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135166

Files:
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/test/DebugInfo/return-same-line-merge.ll
  llvm/unittests/IR/MetadataTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135166.465043.patch
Type: text/x-patch
Size: 8414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221004/dc7c2f7d/attachment.bin>


More information about the llvm-commits mailing list