This is an archive of the discontinued LLVM Phabricator instance.

Fix inconsistency with/without debug information (-g)
ClosedPublic

Authored by jeroen.dobbelaere on Jul 18 2018, 2:58 AM.

Details

Summary

This fixes an inconsistency in code generation when compiling with or without debug information (-g).
When debug information is available in an empty block, the original test would fail, resulting in possibly different code.

Diff Detail

Repository
rL LLVM

Event Timeline

Hi Jeroen, any chance you could add a small test to ensure we'd notice if this regresses in the future?

Hi Jeroen, any chance you could add a small test to ensure we'd notice if this regresses in the future?

Yes, I am working on it.

  • Updated existing (related) testcase to actually test something
  • Added new testcase showing the problem

Please rename the new test to simply 'codegenprepare-and-debug.ll` (the convention of a date on the test name is obsolete, we don't do that for new tests anymore).

llvm/test/Other/2018-07-20-codegenprepare-and-debug.ll
3 ↗(On Diff #156463)

It would be good to be explicit about the X86 dependency:
; REQUIRES: x86-registered-target

4 ↗(On Diff #156463)

it's should be its here.

Looks good to me, but I'll defer to Paul

It seems like the metadata could be reduced further. In particular, do you really need all those different types? The dbg.value needs only !11, I think you should be able to remove !12 through !18 (and references to them).

Reduced the debug information.

I am not sure it is minimal now, but when I tried removing more, I started getting 'invalid debug info' messages.

Found one extra line of debug info that could be removed.

vsk added a subscriber: vsk.Jul 25 2018, 10:40 AM

Please run the test through llvm-as | llvm-dis, this will fix the numbering of the DI nodes.

Reassembled to reset the debug id's

probinson accepted this revision.Jul 26 2018, 10:43 AM

Reassembled to reset the debug id's

Oh nice! I wasn't aware of that trick.

The other thing we like in debug-info tests, is to reduce the function attributes as much as possible. I suspect you can eliminate attributes #1 and instead have @foobar use #0. Do that and LGTM.

This revision is now accepted and ready to land.Jul 26 2018, 10:43 AM

Reduced function attributes.

! In D49467#1177034, @probinson wrote:
Oh nice! I wasn't aware of that trick.

You just need to remember to take a copy of the 'comments' in your file and to copy those manually. Otherwise, the test driver is gone (as I noticed the hard way).

JDevlieghere accepted this revision.Jul 29 2018, 10:06 AM

Jonas, Paul,

could one of you commit this change ?

Thanks !

Jeroen Dobbelaere

This revision was automatically updated to reflect the committed changes.