Skip to content

Commit 22d7c35

Browse files
committed
formatted docs | msvc-opt-minsize.rs
1 parent c8bcad6 commit 22d7c35

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/ui/codegen/msvc-opt-level-z-no-corruption.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
// A previously outdated version of LLVM caused compilation failures on Windows
2-
// specifically with optimization level `z`. After the update to a more recent LLVM
3-
// version, this test checks that compilation and execution both succeed.
4-
// See https://github.com/rust-lang/rust/issues/45034
1+
//! Test that opt-level=z produces correct code on Windows MSVC targets.
2+
//!
3+
//! A previously outdated version of LLVM caused compilation failures and
4+
//! generated invalid code on Windows specifically with optimization level `z`.
5+
//! The bug manifested as corrupted base pointers due to incorrect register
6+
//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables).
7+
//! After updating to a more recent LLVM version, this test ensures that
8+
//! compilation and execution both succeed with opt-level=z.
9+
//!
10+
//! Regression test for <https://github.com/rust-lang/rust/issues/45034>.
511
612
//@ ignore-cross-compile
713
// Reason: the compiled binary is executed
814
//@ only-windows
9-
// Reason: the observed bug only occurs on Windows
15+
// Reason: the observed bug only occurred on Windows MSVC targets
1016
//@ run-pass
1117
//@ compile-flags: -C opt-level=z
1218

@@ -20,8 +26,8 @@ fn foo(x: i32, y: i32) -> i64 {
2026
#[inline(never)]
2127
fn bar() {
2228
let _f = Box::new(0);
23-
// This call used to trigger an LLVM bug in opt-level z where the base
24-
// pointer gets corrupted, see issue #45034
29+
// This call used to trigger an LLVM bug in opt-level=z where the base
30+
// pointer gets corrupted due to incorrect register allocation
2531
let y: fn(i32, i32) -> i64 = test::black_box(foo);
2632
test::black_box(y(1, 2));
2733
}

0 commit comments

Comments
 (0)