This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Make DILocation::getMergedLocation to return a dummy location instead of nullptr
Needs ReviewPublic

Authored by twoh on Feb 14 2017, 12:08 AM.

Details

Summary

Currently, DILocation::getMergedLocation returns nullptr if LocA and LocB come from different locations so that they can be discriminated. However, dropping metadata by returning nullptr may cause a problem when handling inlinable callsites, as discussed in PR31891. Since inlinable calls are required to have a scope information, if two inlinable calls are hoisted and merged, and the merged instruction does not have a debug location info because debug locations of original instructions are different, module verifier fails. For this reason r294250 has been reverted.

This patch makes getMergedLocation returning nullptr only when either LocA or LocB is a nullptr. Otherwise, if LocA and LocB can be discriminated, the function returns a dummy location of (line: 0, column: 0). It asserts that LocA and LocB are in the same scope considering inlining context, and use that scope for the dummy location info to return. This assertion might be unnecessary considering that the return value is a dummy location anyway, but I think performing the merge between two DILocation in different scope should not be permitted.

Event Timeline

twoh created this revision.Feb 14 2017, 12:08 AM

FYI. An alternative fix for this same issue has been already uploaded by Adrian as review D29833.

twoh added a comment.Feb 14 2017, 9:18 AM

Oops, I missed it. Thanks!

pmatos added a subscriber: pmatos.Oct 19 2017, 2:29 AM