This is an archive of the discontinued LLVM Phabricator instance.

[Reassociate] Do not drop debug location if replacement is missing
ClosedPublic

Authored by dstenb on Aug 18 2017, 2:34 AM.

Details

Summary

When reassociating an expression, do not drop the instruction's
original debug location in case the replacement location is
missing.

The debug location must at least not be dropped for inlinable
callsites of debug-info-bearing functions in debug-info-bearing
functions. Failing to do so would result in an "inlinable function "
"call in a function with debug info must have a !dbg location"
error in the verifier.

As preserving the original debug location is not expected
to result in overly jumpy debug line information, it is
preserved for all other cases too.

This fixes PR34231:
https://bugs.llvm.org/show_bug.cgi?id=34231

Diff Detail

Event Timeline

dstenb created this revision.Aug 18 2017, 2:34 AM
dstenb edited the summary of this revision. (Show Details)Aug 18 2017, 2:37 AM

I fully understand the rationale behind this patch and I think it is good, but why is it ok/desirable to drop the debug info in all other cases?

test/Transforms/Reassociate/keep-inlinable-fn-dbgloc.ll
1

This test is missing a CHECK (otherwise it would work even after symlinking opt to /bin/true :-)

I fully understand the rationale behind this patch and I think it is good, but why is it ok/desirable to drop the debug info in all other cases?

Good question!

My original reasoning was that it would be good to drop the debug location in other cases to avoid jumpy line information. Now when I take another look at the pass I'm really starting to doubt if that really is a valid concern. I have not been able to create a reproducer that showcases that problem clearly; however, as I'm not very knowledgeable about the pass, it might as well be due to limitations in my imagination.

It is maybe better to not drop the debug information in the other cases.

davide edited edge metadata.Aug 21 2017, 12:59 PM

I don't think we should drop DI in other cases (your reasoning is correct).

lib/Transforms/Scalar/Reassociate.cpp
2101

auto

test/Transforms/Reassociate/keep-inlinable-fn-dbgloc.ll
1

Indeed :) And we have evidence this happened in the past

dstenb updated this revision to Diff 112299.Aug 23 2017, 1:03 AM
dstenb retitled this revision from [Reassociate] Do not drop debug locations for inlinable calls to [Reassociate] Do not drop debug location if replacement is missing.
dstenb edited the summary of this revision. (Show Details)

Changed so that the debug location is kept in the other cases.
Added CHECK statements (thanks for pointing that out!).

dstenb marked an inline comment as done.Aug 23 2017, 1:04 AM
dstenb added inline comments.
test/Transforms/Reassociate/keep-inlinable-fn-dbgloc.ll
1

Fixed in the latest patch. Thanks for pointing that out!

aprantl accepted this revision.Aug 23 2017, 9:05 AM
This revision is now accepted and ready to land.Aug 23 2017, 9:05 AM
davide accepted this revision.Aug 23 2017, 2:23 PM

LGTM

This revision was automatically updated to reflect the committed changes.