Skip to content

Allow volatile accesses to trap #610

@RalfJung

Description

@RalfJung

I think we should allow all volatile accesses to trap. The reasons are summarized well by @nikic in llvm/llvm-project#192992:

  • This gives a well-defined (if not very ergonomic) way to interact with potentially trapping memory.
  • It is what C will apparently do in future versions of the standard, and it would IMO be bad if Rust had stricter requirements than C in this space.

This would in particular mean that volatile accesses are "UB barriers" in the sense that UB happening after a volatile operation cannot affect what the program does before that operation.

@rust-lang/opsem any objections, or should be move this to FCP?

To actually implement this:

  • For stores, we just have to change the docs. LLVM already considers those not-willreturn and hence treats trapping stores correctly.
  • For loads, we have to either wait until we have a version of LLVM that includes this PR, or we have to find some way to adjust our volatile load lowering that removes the willreturn assumption on the LLVM side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions