Expose LLVM atomic memcpy in intrinsics?

Would it be possible to add LLVM’s atomic memcpy operations to core and std's intrinsics modules? In particular, the llvm.memcpy.element.unordered.atomic, llvm.memmove.element.unordered.atomic, and ‘llvm.memset.element.unordered.atomic intrinsics.

What is the process for a) getting this approved and b) going through the process of adding them?

I think they can be just added, since they will never be stable?

In the long term, I am worried about effect of LLVM intrinsics usage to alternative non-LLVM backends, although so far it seems manageable.

Good point.

I agree in the general case, although in this particular case, even if we expose them through a stable facade, it'd be trivial to implement as a simple loop of atomic operations on for non-LLVM backends.

To avoid that these things need stable wrapper APIs, which as it were I happen to be interested in.

I'm not sure exactly how llvm.memset.element.unordered.atomic relates to, say, core::intrinsics::volatile_store (which has a stable wrapper std::ptr::write_volatile), but I'd really like an analogue for that for doing multiple writes of the same value.

I'm thinking something with a name along the lines of one of the following:

  • core::ptr::write_volatile_many
  • core::ptr::fill_volatile
  • core::ptr::set_volatile

The volatile intrinsics are not concurrency-safe; it's UB to use them to operate on memory which is being concurrently modified.

1 Like

OK posted this issue: https://github.com/rust-lang/rust/issues/58599

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.