- Fix alignment for uint128 to 16 with WASM targets.

- Incorrect assert in struct alignment checking #2841
- Packed structs sometimes not lowered as such.
This commit is contained in:
Christoffer Lerno
2026-01-25 23:05:43 +01:00
parent 4899ee14e2
commit e901a3de55
9 changed files with 50 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ fn int test5(ichar x)
return y.foo + y.bar;
}
// { i32, i16, i16 }
// <{ i32, i16, i16 }>
struct Foo6 @packed
{
int a;
@@ -76,16 +76,15 @@ Foo6 foo6 = { 1, 2, 3 };
%Foo3 = type <{ i8, i64, [7 x i8] }>
%Foo4 = type <{ i8, i64 }>
%Foo5 = type { i32, [12 x i8], i8, [15 x i8] }
%Foo6 = type { i32, i16, i16 }
%Foo6 = type <{ i32, i16, i16 }>
@struct2.foo1 = local_unnamed_addr global %Foo1 <{ i64 1, i8 2, [3 x i8] undef }>, align 4
@struct2.foo2 = local_unnamed_addr global %Foo2 <{ i8 1, i64 2, [3 x i8] undef }>, align 4
@struct2.foo3 = local_unnamed_addr global %Foo3 <{ i8 1, i64 2, [7 x i8] undef }>, align 8
@struct2.foo4 = local_unnamed_addr global %Foo4 <{ i8 1, i64 2 }>, align 1
@struct2.foo5 = local_unnamed_addr global %Foo5 { i32 1, [12 x i8] undef, i8 2, [15 x i8] undef }, align 16
@struct2.foo6 = local_unnamed_addr global %Foo6 { i32 1, i16 2, i16 3 }, align 1
@struct2.foo6 = local_unnamed_addr global %Foo6 <{ i32 1, i16 2, i16 3 }>, align 1
; Function Attrs:
define i32 @struct2.test5(i8 signext %0) #0 {
entry:
%y = alloca %Foo5, align 16

View File

@@ -36,7 +36,7 @@ fn void main()
/* #expect: test.ll
%Client = type <{ i32, %MsgHeader, i16, [2 x i8], %"ElasticArray{ulong, 1}" }>
%MsgHeader = type { i64 }
%MsgHeader = type <{ i64 }>
%"ElasticArray{ulong, 1}" = type { i64, [1 x i64] }
define void @test.main() #0 {

View File

@@ -0,0 +1,35 @@
// #target: macos-x64
module test;
struct Foo3 @align(8)
{
char foo;
Foo6 bar;
}
struct Foo6 @packed
{
short c;
}
fn int main()
{
Foo3 x;
return 0;
}
/* #expect: test.ll
%Foo3 = type <{ i8, %Foo6, [5 x i8] }>
%Foo6 = type <{ i16 }>
@"$ct.test.Foo3" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.test.Foo6" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 2, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8
define i32 @main() #0 {
entry:
%x = alloca %Foo3, align 8
store i8 0, ptr %x, align 8
%ptradd = getelementptr inbounds i8, ptr %x, i64 1
store i16 0, ptr %ptradd, align 1
ret i32 0
}