This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVM] Fix dbg intrinsic import of killed locations
ClosedPublic

Authored by Dinistro on Aug 11 2023, 8:19 AM.

Details

Summary

This commit ensures that debug intrinsics of killed variables do not
cause a crash of the importer. Killed locations are usually undef
constants, but in infrequent cases can also be metadata nodes, which
caused problems.

Diff Detail

Event Timeline

Dinistro created this revision.Aug 11 2023, 8:19 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Dinistro requested review of this revision.Aug 11 2023, 8:19 AM
zero9178 added inline comments.Aug 11 2023, 8:32 AM
mlir/lib/Target/LLVMIR/ModuleImport.cpp
1783–1784

I think it'd be more robust to not even attempt convertMetadataValue in this case. Checking dbgInstr->isKillLocation() && !isa<ValueAsMetadata>() should catch this case, right?

Dinistro updated this revision to Diff 549439.Aug 11 2023, 9:29 AM

address review comments, add expensive warning, and move the test.

Dinistro marked an inline comment as done.Aug 11 2023, 9:30 AM
Dinistro added inline comments.
mlir/lib/Target/LLVMIR/ModuleImport.cpp
1783–1784

Good idea. I moved the checkout into a static function, as it requires a bit more to match.

This revision is now accepted and ready to land.Aug 11 2023, 9:41 AM
This revision was automatically updated to reflect the committed changes.
Dinistro marked an inline comment as done.