Skip to content

[strict provenance] Make The strict_provenance APIs Actual Compiler Magic? #95498

Open
@Gankra

Description

@Gankra

This issue is part of the Strict Provenance Experiment - #95228

I left a few little FIXME(strict_provenance_magic) comments around core::ptr to indicate places that might want to become a compiler intrinsic for... Reasons. Currently all of these operations function but it's possible they can function "better" or somehow power better checking/analysis with builtin support.

In particular you probably want with_addr as some kind of instrinsic because the naive impl does a bunch of faffing around when on most platforms it's usize as *mut T and on CHERI this is literally cheri_address_set.

pub fn with_addr(self, addr: usize) -> Self
where
T: Sized,
{
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
//
// In the mean-time, this operation is defined to be "as if" it was
// a wrapping_offset, so we can emulate it as such. This should properly
// restore pointer provenance even under today's compiler.

This discussion is 100% "above my pay grade", I cannot provide any more insight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-strict-provenanceArea: Strict provenance for raw pointersT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions