This is an archive of the discontinued LLVM Phabricator instance.

Update the discriminator assignment algorithm.
ClosedPublic

Authored by danielcdh on Oct 29 2015, 10:33 AM.

Details

Reviewers
dnovillo
davidxl
Summary
  • If a scope has already been assigned a discriminator, do not reassign a nested discriminator for it.
  • If the file and line both match, even if the column does not match, we should assign a new discriminator for the stmt.

original code:
; #1 int foo(int i) {
; #2 if (i == 3 || i == 5) return 100; else return 99;
; #3 }

; i == 3: discriminator 0
; i == 5: discriminator 2
; return 100: discriminator 1
; return 99: discriminator 3

Diff Detail

Event Timeline

danielcdh updated this revision to Diff 38748.Oct 29 2015, 10:33 AM
danielcdh retitled this revision from to Update the discriminator assignment algorithm..
danielcdh updated this object.
danielcdh added reviewers: dnovillo, davidxl.
danielcdh added a subscriber: llvm-commits.
dnovillo added inline comments.Oct 29 2015, 2:12 PM
lib/Transforms/Utils/AddDiscriminators.cpp
219

I don't understand this. You are not using newDebugLoc anymore. Can you show me examples of what you are fixing? The test case is not very clear. Thanks.

danielcdh updated this revision to Diff 38763.Oct 29 2015, 2:30 PM

Sync patch to head and add the source of the test.

danielcdh updated this revision to Diff 38764.Oct 29 2015, 2:33 PM

Updated NewDIL to CurrentDIL.

danielcdh updated this revision to Diff 38765.Oct 29 2015, 2:36 PM

Remove NewDIL and newDebugLoc, which are not used any more.

danielcdh added inline comments.Oct 29 2015, 2:40 PM
lib/Transforms/Utils/AddDiscriminators.cpp
219

Updated NewDIL to CurrentDIL and removed NewDIL.

Updated the testcase to include the original source code.

Without the patch, we will have:

!23 = !DILocation(line: 2, column: 17, scope: !24)
!24 = !DILexicalBlockFile(scope: !20, file: !1, discriminator: 2)
!25 = !DILocation(line: 2, column: 19, scope: !20)
!26 = !DILocation(line: 2, column: 7, scope: !4)

Note that #25 and #26 do not have discriminator 2

And we also see nested discriminator, which is a waste of space.

!27 = !DILocation(line: 2, column: 25, scope: !28)
!28 = !DILexicalBlockFile(scope: !29, file: !1, discriminator: 3)
!29 = !DILexicalBlockFile(scope: !20, file: !1, discriminator: 1)

dnovillo accepted this revision.Oct 29 2015, 2:47 PM
dnovillo edited edge metadata.
dnovillo added inline comments.
lib/Transforms/Utils/AddDiscriminators.cpp
219

Thanks. Could you please add this to the patch description and to the test case? In the test case, it will help a lot if we have a description of what discriminators we are expecting in the source code itself.

Thanks for the fix!

This revision is now accepted and ready to land.Oct 29 2015, 2:47 PM
danielcdh updated this object.Oct 29 2015, 7:37 PM
danielcdh edited edge metadata.
danielcdh closed this revision.Oct 29 2015, 7:41 PM