suboptimal llvm-ir due to missing noalias annotations after mir inlining
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names no source files or tests. Start by reproducing the Rust 1.80 behavior with the provided code and comparing MIR, LLVM IR, and x86-64 output with Rust 1.64; trace how MIR inlining affects noalias information. Done means the optimized output avoids the unnecessary reload and matches the expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100