For the machine instructions, MachineMemOperand is the better place to track the ptr_provenance.
Diff Detail
Event Timeline
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?
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.