blob: 66af5bf1d5d40166753fc75ece36c664378ae019 [file] [log] [blame]
Ralf Jung75d0fdd2024-04-20 13:19:34 +02001//@ test-mir-pass: GVN
Oliver Scherera1ebb942020-05-06 19:28:48 +02002
Camille GILLOTd91bb502023-12-02 20:50:00 +00003// Verify that we do not propagate the contents of this mutable static.
Ulrich Weigand68857332022-12-22 16:33:12 +01004static mut STATIC: u32 = 0x42424242;
Oliver Scherera1ebb942020-05-06 19:28:48 +02005
Camille GILLOT28377272023-09-20 21:43:33 +00006// EMIT_MIR mutable_variable_no_prop.main.GVN.diff
Oliver Scherera1ebb942020-05-06 19:28:48 +02007fn main() {
Camille GILLOTd91bb502023-12-02 20:50:00 +00008 // CHECK-LABEL: fn main(
9 // CHECK: debug x => [[x:_.*]];
10 // CHECK: debug y => [[y:_.*]];
11 // CHECK: [[x]] = const 42_u32;
Scott McMurray249a36f2024-08-18 15:51:53 -070012 // CHECK: [[tmp:_.*]] = copy (*{{_.*}});
Camille GILLOTd91bb502023-12-02 20:50:00 +000013 // CHECK: [[x]] = move [[tmp]];
Scott McMurray249a36f2024-08-18 15:51:53 -070014 // CHECK: [[y]] = copy [[x]];
Oliver Scherera1ebb942020-05-06 19:28:48 +020015 let mut x = 42;
16 unsafe {
17 x = STATIC;
18 }
19 let y = x;
20}