Skip to content

Commit

Permalink
Fortify test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Dec 17, 2023
1 parent 3ea5cfa commit 503af0d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/codegen/overaligned-constant.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
// GVN may create indirect constants with higher alignment than their type requires. Verify that we
// do not ICE during codegen, and that the LLVM constant has the higher alignment.
//
// compile-flags: -O -Zmir-enable-passes=+GVN -Cdebuginfo=2
// compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+GVN
// compile-flags: -Cno-prepopulate-passes
// only-64bit

struct S(i32);

struct SmallStruct(f32, Option<S>, &'static [f32]);

// CHECK: @0 = private unnamed_addr constant
// CHECK-SAME: , align 8

fn main() {
// CHECK-LABEL: @_ZN20overaligned_constant4main
// CHECK: [[full:%_.*]] = alloca %SmallStruct, align 8
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[full]], ptr align 8 @0, i64 32, i1 false)
// CHECK: %b.0 = load i32, ptr @0, align 4,
// CHECK: %b.1 = load i32, ptr getelementptr inbounds ({ i32, i32 }, ptr @0, i32 0, i32 1), align 4
let mut s = S(1);

s.0 = 3;
Expand All @@ -26,6 +34,3 @@ fn main() {
// alignment 8, but only use the `Option<S>` field, at offset 0 with alignment 4.
let SmallStruct(a, b, c) = SMALL_VAL;
}

// CHECK: @0 = private unnamed_addr constant
// CHECK-SAME: , align 8

0 comments on commit 503af0d

Please sign in to comment.