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.
Also see #407.
I think we should allow all volatile accesses to trap. The reasons are summarized well by @nikic in llvm/llvm-project#192992:
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:
willreturnand hence treats trapping stores correctly.willreturnassumption on the LLVM side.Also see #407.