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>.
5
11
6
12
//@ ignore-cross-compile
7
13
// Reason: the compiled binary is executed
8
14
//@ only-windows
9
- // Reason: the observed bug only occurs on Windows
15
+ // Reason: the observed bug only occurred on Windows MSVC targets
10
16
//@ run-pass
11
17
//@ compile-flags: -C opt-level=z
12
18
@@ -20,8 +26,8 @@ fn foo(x: i32, y: i32) -> i64 {
20
26
#[ inline( never) ]
21
27
fn bar ( ) {
22
28
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
25
31
let y: fn ( i32 , i32 ) -> i64 = test:: black_box ( foo) ;
26
32
test:: black_box ( y ( 1 , 2 ) ) ;
27
33
}
0 commit comments