This is an archive of the discontinued LLVM Phabricator instance.

[MachineMemOperand] learn about ptr_provenance
AcceptedPublic

Authored by jeroen.dobbelaere on Aug 3 2021, 7:47 AM.

Details

Summary

For the machine instructions, MachineMemOperand is the better place to track the ptr_provenance.

Diff Detail

Event Timeline

jeroen.dobbelaere requested review of this revision.Aug 3 2021, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 7:04 AM
Zoxc added a subscriber: Zoxc.May 5 2022, 9:21 AM

Given that the provenance gets dropped in https://reviews.llvm.org/D107356, how does it end up in machine operands?

Given that the provenance gets dropped in https://reviews.llvm.org/D107356, how does it end up in machine operands?

Good question. The provenance embedded in the MachineOperand here originates from the ptr_provenance operand in load/store instructions.
Your question does point out that https://reviews.llvm.org/D107356 (aka CodeGen/IntrinsicLowering) is too early if we want to track the more complex forms
of provenance after lowering.

Given that the provenance gets dropped in https://reviews.llvm.org/D107356, how does it end up in machine operands?

Good question. The provenance embedded in the MachineOperand here originates from the ptr_provenance operand in load/store instructions.
Your question does point out that https://reviews.llvm.org/D107356 (aka CodeGen/IntrinsicLowering) is too early if we want to track the more complex forms
of provenance after lowering.

Having looked deeper into it: IntrinsicLowering.cpp seems only to be used for the interpreter. There it makes sense to eliminate the noalias/ptr_provenance intrinsics.
During code generation, SelectionDAG is taking care of seeing through the intrinsics while lowering. But, the original llvm-IR (with intrinsics) stays available for the alias analysis. So the machine operands must be able to see it.
(Although you might need to enable AA analysis on machine ir)

LGTM. Can you please add a LIT test with a check that ptr_provenance is printed or is it useless?

arsenm added a subscriber: arsenm.Jan 17 2023, 2:06 PM

Needs some testing, especially MIR print and parse. Can you not simply look through the existing Value to find the provenance?

Rebased to: 8c7cfa357280dd93d33b10bbba0fe33797e27d63 (Feb 14, 2023)

Added MIR parser support and testcase.

asbirlea accepted this revision.Apr 11 2023, 10:13 AM
This revision is now accepted and ready to land.Apr 11 2023, 10:13 AM