This is an archive of the discontinued LLVM Phabricator instance.

Fix out-of-order stepping behavior in programs with hoisted constants.
ClosedPublic

Authored by ormris on Sep 20 2017, 10:43 AM.

Details

Summary

When the Constant Hoisting pass moves expensive constants into a common block,
it assignes a debug location equal to the last use of that constant. While this
is certainly intuitive, it places the constant in an out-of-order location,
according to the debug location information. This produces out-of-order
stepping when debugging programs effected by this pass.

This patch creates in-order stepping behavior by removing the debug location
information from hoisted constants.

Diff Detail

Repository
rL LLVM

Event Timeline

ormris created this revision.Sep 20 2017, 10:43 AM

When the Constant Hoisting pass moves expensive constants into a common block,
it assignes a debug location equal to the last use of that constant. While this
is certainly intuitive, it places the constant in an out-of-order location,
according to the debug location information. This produces out-of-order
stepping when debugging programs effected by this pass.

This patch creates in-order stepping behavior by removing the debug location
information from hoisted constants.

craig.topper added inline comments.Sep 20 2017, 4:34 PM
lib/Transforms/Scalar/ConstantHoisting.cpp
745 ↗(On Diff #116029)

This code now longer matches the comment. And the asserts are no longer required since they existed to ensure validity of the previous behavior.

ormris updated this revision to Diff 116114.Sep 20 2017, 4:41 PM

Updating D38088: Fix out-of-order stepping behavior in programs with hoisted constants.

Change list:

  • Remove unnecessary asserts
  • Edit comment to ensure consistency with new behavior
echristo edited edge metadata.

Adding Paul since he's looked at this stuff extensively.

probinson edited edge metadata.Sep 21 2017, 4:39 PM

This came out of our sample-PGO work, wasn't sure it would be kosher for me to approve a patch from the guy in the next cube.
It's completely in line with the other similar patches that Andrea and Dehao have been doing. So if Craig is happy, I'm happy.

I mean, I disagree with the general behavior, but I think I've lost that argument so if it's consistent go ahead with it :)

craig.topper edited edge metadata.Sep 21 2017, 4:46 PM

I'm not sure I know enough about debug info to approve this myself. I just knew enough to know that the comment didn't match up after the change.

probinson accepted this revision.Sep 21 2017, 4:56 PM

Well then! LGTM.

I mean, I disagree with the general behavior, but I think I've lost that argument so if it's consistent go ahead with it :)

I am not super excited about the tactic either, but preserving the line info on instructions that get moved around like this is messing up an important consumer (SPGO) so I'm willing to tolerate it until we can come up with something better.

This revision is now accepted and ready to land.Sep 21 2017, 4:56 PM

Great! Thanks @craig.topper for your review comments. Could someone commit this change? I don't have commit access currently.

ormris updated this revision to Diff 122193.Nov 8 2017, 6:00 PM

Updated the pass to use the merge API. This version merges the locations of all uses
of the hoisted constant, as well as the location of the instruction at the insertion
point.

ormris requested review of this revision.Nov 8 2017, 6:01 PM
ormris edited edge metadata.
ormris added a reviewer: aprantl.
aprantl accepted this revision.Nov 9 2017, 11:29 AM
This revision is now accepted and ready to land.Nov 9 2017, 11:29 AM

Paul, can you commit this?

Thanks for the review!

This revision was automatically updated to reflect the committed changes.