Skip to content

unaligned_volatile_store emits aligned stores for some types #158897

Description

@scottmcm

Demo: https://rust.godbolt.org/z/MfWTbvxE8

struct Foo([u32; 4]);

#[unsafe(no_mangle)]
pub fn demo(p: *mut Foo, num: Foo) {
    unsafe { std::intrinsics::unaligned_volatile_store(p, num) }
}

On rustc 1.99.0-nightly (3659db0 2026-07-05)

define void @demo(ptr noundef %p, ptr dead_on_return noalias nofree noundef align 4 captures(address) dereferenceable(16) %num) unnamed_addr {
start:
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %p, ptr align 4 %num, i64 16, i1 true)
  ;                                    ^^^^^^^         ^^^^^^^
  ret void
}

Thankfully this intrinsic is so unstable it doesn't even have an unstable wrapper in the library.

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions