5 // This test checks that we annotate alignment loads from vtables with nonzero range metadata,
6 // and that this allows LLVM to eliminate redundant `align >= 1` checks.
12 pub struct WrapperWithAlign1<T: ?Sized> { x: u8, y: T }
14 pub struct WrapperWithAlign2<T: ?Sized> { x: u16, y: T }
16 pub struct Struct<W: ?Sized> {
21 // CHECK-LABEL: @eliminates_runtime_check_when_align_1
23 pub fn eliminates_runtime_check_when_align_1(
24 x: &Struct<WrapperWithAlign1<dyn Trait>>
25 ) -> &WrapperWithAlign1<dyn Trait> {
26 // CHECK: load [[USIZE:i[0-9]+]], {{.+}} !range [[RANGE_META:![0-9]+]]
33 // CHECK-LABEL: @does_not_eliminate_runtime_check_when_align_2
35 pub fn does_not_eliminate_runtime_check_when_align_2(
36 x: &Struct<WrapperWithAlign2<dyn Trait>>
37 ) -> &WrapperWithAlign2<dyn Trait> {
38 // CHECK: [[X0:%[0-9]+]] = load [[USIZE]], {{.+}} !range [[RANGE_META]]
39 // CHECK: [[X1:%[0-9]+]] = icmp {{.+}} [[X0]]
40 // CHECK: [[X2:%[0-9]+]] = select {{.+}} [[X1]]
45 // CHECK: [[RANGE_META]] = !{[[USIZE]] 1, [[USIZE]] 0}