This is an archive of the discontinued LLVM Phabricator instance.

[ptr_provenance] Bitcode reader/writer support for the optional ptr_provenance operand of load/store instructions
AcceptedPublic

Authored by jeroen.dobbelaere on Jun 14 2021, 3:03 PM.

Details

Summary

This patch introduces bitcode reader/writer support for the optional ptr_provenance operand of load/store instructions.

This is done in a backwards and future compatible way: when present, an extra 'bool true' + the value and type are pushed.
When reading, if there are extra values, the first bool indicates if a ptr_provenance operand is available or not.

If in future more optional values are needed, extra bools can be added to indicate that they are present. As soon as one extra
optional value is emitted, the status of the others should also be emitted.

Note: this corresponds to D87254

Diff Detail

Event Timeline

jeroen.dobbelaere requested review of this revision.Jun 14 2021, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2021, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 7:01 AM

Why do we add the boolean, isn't a nullptr/unknown provenance just as good?

Why do we add the boolean, isn't a nullptr/unknown provenance just as good?

(I misinterpreted this as pushing an actual '0 pointer' to indicate that the ptr_provenance is not used. As far as I see, that is not possible.)
The boolean is to indicate that we do (or do not) have the optional ptr_provenance. It allows us to add more arguments to these instructions later (if that would be needed).
Just depending on the 'number of arguments' would not be sufficient here. So this is for forwards compatibility.

A nullptr, or unknown_provenance have their own meaning in the ptr_provenance world. At this point, a missing ptr_provenance argument indicates that the provenance is that of the pointer argument.
At a later time we can decide to move to a mechanism that the ptr_provenance should always be present and then the 'unknown_provenance' would be the best choice if its was missing.

This revision is now accepted and ready to land.Dec 7 2022, 3:29 PM