Skip to content

Allow volatile accesses to trap #610

Description

@RalfJung

I think we should allow all volatile accesses to trap. This gives a well-defined (if not very ergonomic) way to interact with potentially trapping memory. LLVM already made this change, we just have to expose it.

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. It seems like C will specify this for all observable events in the future; it would be bad if Rust had more footguns here than C does.

@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.

Also see #407.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions