This is an archive of the discontinued LLVM Phabricator instance.

Add a unit test for DILocation::getMergedLocation()
ClosedPublic

Authored by aprantl on Aug 24 2018, 3:49 PM.

Details

Summary

This is a unit test for DILocation::getMergedLocation() that exposes a bug in the implementation of r340583. (You'll need to build with assertions enabled to see it.)

Diff Detail

Repository
rL LLVM

Event Timeline

aprantl created this revision.Aug 24 2018, 3:49 PM
aprantl added inline comments.Aug 24 2018, 3:57 PM
unittests/IR/MetadataTest.cpp
924 ↗(On Diff #162492)

This triggers an assertion in DILocation::getScope() because the DIFile is not a DILocalScope.

Some ideas for fixing this:

  • create a new dummy DISubprogram(name: "$llvm$merged$foo$bar")
  • randomly pick one location's scope (it's line 0 after all)
This revision was not accepted when it landed; it landed in state Needs Review.Aug 24 2018, 4:31 PM
This revision was automatically updated to reflect the committed changes.

Could you still come up with a practical test case for this? (doesn't
necessarily need to be checked in, to be honest - but something to validate
that this use case/support is needed & not working around a bug (& if it is
working around a bug, that we know about it so we can remove the workaround
eventually & not leave it in as folklore and cruft))

I can imagine that there could be cases where there would be no common
scope - due to inlining into a nodebug function (we have that classic
assertion to ensure all scope chains lead to the DISubprogram that contains
those locations - but that does not apply if there is no DISubprogram for a
function - if it is nodebug and has had debug info inlined into it (which
is still useful if, then, the nodebug function is inlined into somewhere
else)). So maybe you can search around there.

Though I also think probably the right answer here is not to pick one of
the two locations, but to drop the location entirely.

  • Dave