This is an archive of the discontinued LLVM Phabricator instance.

Avoid misleading line table when Localizer sinks an instruction to another basic block
Needs ReviewPublic

Authored by aprantl on Jun 29 2021, 5:16 PM.

Details

Summary

This patch attaches the source location of the insertion point to the localized instruction, if it comes from a different basic block. Preserving the original source location would create a misleading line table.

Cf. https://www.llvm.org/docs/HowToUpdateDebugInfo.html#when-to-drop-an-instruction-location

rdar://78489600

Diff Detail

Event Timeline

aprantl created this revision.Jun 29 2021, 5:16 PM
aprantl requested review of this revision.Jun 29 2021, 5:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2021, 5:16 PM
vsk added a comment.Jun 30 2021, 9:25 AM

Is this a case where the guidance (as-written) suggests dropping the location instead?

Is this a case where the guidance (as-written) suggests dropping the location instead?

Yes. And I wonder if we should update the guidance. Literally dropping the location would result in the last instruction's location being carried forward. We don't want the inserted instruction to keep its location from the other basic block, but associating it with the previous instruction's location would also be wrong since we are inserting it on behalf of the next instruction (the insertion point). Maybe this isn't so much sinking an instruction but expanding an existing instruction?

For context, the bugreport that motivated this was a sanitizer diagnostic that we want to happen on behalf of the insertion point source location.

vsk added a comment.Jul 1 2021, 5:46 PM

Is this a case where the guidance (as-written) suggests dropping the location instead?

Yes. And I wonder if we should update the guidance. Literally dropping the location would result in the last instruction's location being carried forward. We don't want the inserted instruction to keep its location from the other basic block, but associating it with the previous instruction's location would also be wrong since we are inserting it on behalf of the next instruction (the insertion point). Maybe this isn't so much sinking an instruction but expanding an existing instruction?

Applying UseMI's location also seems wrong in some sense: the only right one would be the original, but it can't be kept. It'd also be awkward if UseMI is moved by some subsequent transform while LocalizedMI isn't.

ormris removed a subscriber: ormris.Jan 24 2022, 11:51 AM