Skip to content

Commit

Permalink
Add a codegen test for transparent aggregates
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Apr 13, 2024
1 parent 5d593cf commit ab19c5f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/codegen/transparent-aggregates.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ compile-flags: -O -C no-prepopulate-passes

#![crate_type = "lib"]

#[repr(transparent)]
struct Transparent32(u32);

// CHECK: i32 @make_transparent(i32 noundef %x)
#[no_mangle]
pub fn make_transparent(x: u32) -> Transparent32 {
// CHECK: %a = alloca i32
// CHECK: store i32 %x, ptr %a
// CHECK: %[[TEMP:.+]] = load i32, ptr %a
// CHECK: ret i32 %[[TEMP]]
let a = Transparent32(x);
a
}

// CHECK-LABEL: { i32, i32 } @make_2_tuple(i32 noundef %x)
#[no_mangle]
pub fn make_2_tuple(x: u32) -> (u32, u32) {
// CHECK: %pair = alloca { i32, i32 }
// CHECK: store i32
// CHECK: store i32
// CHECK: load i32
// CHECK: load i32
let pair = (x, x);
pair
}

0 comments on commit ab19c5f

Please sign in to comment.