|  | 
|  | 1 | +// Test that miri respects the `target.min_global_align` value for the target. | 
|  | 2 | +// | 
|  | 3 | +// The only way to observe its effect currently is to test for the alignment of statics with a | 
|  | 4 | +// natural alignment of 1 on s390x. On that target, the `min_global_align` is 2 bytes. | 
|  | 5 | +use core::ptr; | 
|  | 6 | + | 
|  | 7 | +static T0: bool = true; | 
|  | 8 | +static T1: bool = true; | 
|  | 9 | +static T2: bool = true; | 
|  | 10 | +static T3: bool = true; | 
|  | 11 | +static T4: bool = true; | 
|  | 12 | +static T5: bool = true; | 
|  | 13 | +static T6: bool = true; | 
|  | 14 | +static T7: bool = true; | 
|  | 15 | +static T8: bool = true; | 
|  | 16 | +static T9: bool = true; | 
|  | 17 | + | 
|  | 18 | +static F0: bool = false; | 
|  | 19 | +static F1: bool = false; | 
|  | 20 | +static F2: bool = false; | 
|  | 21 | +static F3: bool = false; | 
|  | 22 | +static F4: bool = false; | 
|  | 23 | +static F5: bool = false; | 
|  | 24 | +static F6: bool = false; | 
|  | 25 | +static F7: bool = false; | 
|  | 26 | +static F8: bool = false; | 
|  | 27 | +static F9: bool = false; | 
|  | 28 | + | 
|  | 29 | +fn main() { | 
|  | 30 | +    let min_align = if cfg!(target_arch = "s390x") { 2 } else { 1 }; | 
|  | 31 | + | 
|  | 32 | +    assert!(ptr::from_ref(&T0).addr().is_multiple_of(min_align)); | 
|  | 33 | +    assert!(ptr::from_ref(&T1).addr().is_multiple_of(min_align)); | 
|  | 34 | +    assert!(ptr::from_ref(&T2).addr().is_multiple_of(min_align)); | 
|  | 35 | +    assert!(ptr::from_ref(&T3).addr().is_multiple_of(min_align)); | 
|  | 36 | +    assert!(ptr::from_ref(&T4).addr().is_multiple_of(min_align)); | 
|  | 37 | +    assert!(ptr::from_ref(&T5).addr().is_multiple_of(min_align)); | 
|  | 38 | +    assert!(ptr::from_ref(&T6).addr().is_multiple_of(min_align)); | 
|  | 39 | +    assert!(ptr::from_ref(&T7).addr().is_multiple_of(min_align)); | 
|  | 40 | +    assert!(ptr::from_ref(&T8).addr().is_multiple_of(min_align)); | 
|  | 41 | +    assert!(ptr::from_ref(&T9).addr().is_multiple_of(min_align)); | 
|  | 42 | + | 
|  | 43 | +    assert!(ptr::from_ref(&F0).addr().is_multiple_of(min_align)); | 
|  | 44 | +    assert!(ptr::from_ref(&F1).addr().is_multiple_of(min_align)); | 
|  | 45 | +    assert!(ptr::from_ref(&F2).addr().is_multiple_of(min_align)); | 
|  | 46 | +    assert!(ptr::from_ref(&F3).addr().is_multiple_of(min_align)); | 
|  | 47 | +    assert!(ptr::from_ref(&F4).addr().is_multiple_of(min_align)); | 
|  | 48 | +    assert!(ptr::from_ref(&F5).addr().is_multiple_of(min_align)); | 
|  | 49 | +    assert!(ptr::from_ref(&F6).addr().is_multiple_of(min_align)); | 
|  | 50 | +    assert!(ptr::from_ref(&F7).addr().is_multiple_of(min_align)); | 
|  | 51 | +    assert!(ptr::from_ref(&F8).addr().is_multiple_of(min_align)); | 
|  | 52 | +    assert!(ptr::from_ref(&F9).addr().is_multiple_of(min_align)); | 
|  | 53 | +} | 
0 commit comments