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.