suboptimal llvm-ir due to missing noalias annotations after mir inlining #129128
Open
Description
suboptimal llvm-ir due to missing noalias annotations after mir inlining
Code
I tried this code:
#[inline(never)]
#[no_mangle]
pub unsafe fn noalias_ptr(x: *mut i32, y: *mut i32) -> i32 {
#[inline]
fn noalias_ref(x: &mut i32, y: &mut i32) -> i32 {
*x = 16;
*y = 12;
*x
}
let x = &mut *x;
let y = &mut *y;
noalias_ref(x, y)
}
I expected to see this happen: generated asm on x86-64
noalias_ptr:
mov dword ptr [rdi], 16
mov dword ptr [rsi], 12
mov eax, 16
ret
Instead, this happened: generated asm on x86-64
noalias_ptr:
mov dword ptr [rdi], 16
mov dword ptr [rsi], 12
mov eax, dword ptr [rdi]
ret
Version it worked on
It most recently worked on: rust 1.64
Version with regression
rustc --version --verbose
:
rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: x86_64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.7
Compiler returned: 0
Fun fact
changing noalias_ref(x, y)
to (noalias_ref as fn(_, _) -> _)(x, y)
"fixes" the issue in this case, since it seems to block the mir inliner
@rustbot modify labels: +regression-from-stable-to-stable-regression-untriaged
Activity