From cf75e3e664d9e61294c14c91839539c2a8d3bd03 Mon Sep 17 00:00:00 2001 From: visualfc Date: Wed, 17 Jul 2024 10:42:04 +0800 Subject: [PATCH] ssa: abiNamed set underlying size --- cl/_testgo/equal/out.ll | 6 +++--- cl/_testgo/errors/out.ll | 4 ++-- cl/_testgo/ifaceconv/out.ll | 6 +++--- cl/_testgo/ifaceprom/out.ll | 4 ++-- cl/_testgo/interface/out.ll | 8 ++++---- cl/_testgo/invoke/out.ll | 16 ++++++++-------- cl/_testgo/reader/out.ll | 10 +++++----- cl/_testgo/struczero/out.ll | 6 +++--- cl/_testrt/abinamed/out.ll | 28 ++++++++++++++-------------- cl/_testrt/eface/out.ll | 4 ++-- cl/_testrt/makemap/out.ll | 10 +++++----- cl/_testrt/typed/out.ll | 6 +++--- internal/runtime/z_face.go | 14 ++++++++------ ssa/abitype.go | 8 +++++++- 14 files changed, 69 insertions(+), 61 deletions(-) diff --git a/cl/_testgo/equal/out.ll b/cl/_testgo/equal/out.ll index 747b618fb..2beb4cd35 100644 --- a/cl/_testgo/equal/out.ll +++ b/cl/_testgo/equal/out.ll @@ -609,7 +609,7 @@ _llgo_6: ; preds = %_llgo_5, %_llgo_4 br i1 %20, label %_llgo_7, label %_llgo_8 _llgo_7: ; preds = %_llgo_6 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + %21 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 48, i64 0, i64 0) store ptr %21, ptr @_llgo_main.T, align 8 br label %_llgo_8 @@ -749,7 +749,7 @@ _llgo_12: ; preds = %_llgo_11, %_llgo_10 br i1 %103, label %_llgo_13, label %_llgo_14 _llgo_13: ; preds = %_llgo_12 - %104 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + %104 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0, i64 0) store ptr %104, ptr @_llgo_main.N, align 8 br label %_llgo_14 @@ -897,7 +897,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplu declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/errors/out.ll b/cl/_testgo/errors/out.ll index 85e7f553c..5ba87d888 100644 --- a/cl/_testgo/errors/out.ll +++ b/cl/_testgo/errors/out.ll @@ -99,7 +99,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) define void @"main.init$after"() { _llgo_0: - %0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 1) + %0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 0, i64 1) store ptr %0, ptr @_llgo_main.errorString, align 8 %1 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 0 @@ -270,7 +270,7 @@ _llgo_6: ; preds = %_llgo_5, %_llgo_4 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/ifaceconv/out.ll b/cl/_testgo/ifaceconv/out.ll index 444d68c2a..f29e80e4b 100644 --- a/cl/_testgo/ifaceconv/out.ll +++ b/cl/_testgo/ifaceconv/out.ll @@ -1028,7 +1028,7 @@ _llgo_10: ; preds = %_llgo_9, %_llgo_8 br i1 %160, label %_llgo_11, label %_llgo_12 _llgo_11: ; preds = %_llgo_10 - %161 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 1) + %161 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 1, i64 1) store ptr %161, ptr @_llgo_main.C1, align 8 br label %_llgo_12 @@ -1138,7 +1138,7 @@ _llgo_16: ; preds = %_llgo_15, %_llgo_14 br i1 %220, label %_llgo_17, label %_llgo_18 _llgo_17: ; preds = %_llgo_16 - %221 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 2, i64 2) + %221 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 2, i64 2) store ptr %221, ptr @_llgo_main.C2, align 8 br label %_llgo_18 @@ -1276,7 +1276,7 @@ declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr) declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/ifaceprom/out.ll b/cl/_testgo/ifaceprom/out.ll index 5d3955ae1..51d71bdb0 100644 --- a/cl/_testgo/ifaceprom/out.ll +++ b/cl/_testgo/ifaceprom/out.ll @@ -614,7 +614,7 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"() define void @"main.init$after"() { _llgo_0: - %0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 2, i64 2) + %0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 2, i64 2) store ptr %0, ptr @_llgo_main.impl, align 8 %1 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8 %2 = icmp eq ptr %1, null @@ -948,7 +948,7 @@ _llgo_12: ; preds = %_llgo_11, %_llgo_10 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/interface/out.ll b/cl/_testgo/interface/out.ll index 3df563204..b1fb20a10 100644 --- a/cl/_testgo/interface/out.ll +++ b/cl/_testgo/interface/out.ll @@ -255,7 +255,7 @@ _llgo_0: br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 2, i64 2) + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 8, i64 2, i64 2) call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %2) store ptr %2, ptr @_llgo_main.Game1, align 8 br label %_llgo_2 @@ -278,7 +278,7 @@ _llgo_3: ; preds = %_llgo_2 %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %9, i32 0, i32 1 store i64 0, ptr %11, align 4 %12 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %9, align 8 - %13 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 2) + %13 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0, i64 2) %14 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %13) %15 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %8, ptr %14, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %12, i1 true) %16 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 @@ -443,7 +443,7 @@ _llgo_10: ; preds = %_llgo_9, %_llgo_6 br i1 %103, label %_llgo_11, label %_llgo_12 _llgo_11: ; preds = %_llgo_10 - %104 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 1) + %104 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0, i64 1) store ptr %104, ptr @_llgo_main.Game2, align 8 br label %_llgo_12 @@ -655,7 +655,7 @@ _llgo_20: ; preds = %_llgo_19, %_llgo_18 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr) diff --git a/cl/_testgo/invoke/out.ll b/cl/_testgo/invoke/out.ll index aedda48c5..9eed1423f 100644 --- a/cl/_testgo/invoke/out.ll +++ b/cl/_testgo/invoke/out.ll @@ -650,7 +650,7 @@ _llgo_0: br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 2) + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 1, i64 2) store ptr %2, ptr @_llgo_main.T, align 8 br label %_llgo_2 @@ -909,7 +909,7 @@ _llgo_14: ; preds = %_llgo_13, %_llgo_12 br i1 %143, label %_llgo_15, label %_llgo_16 _llgo_15: ; preds = %_llgo_14 - %144 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 2, i64 1, i64 1) + %144 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 2, i64 8, i64 1, i64 1) store ptr %144, ptr @_llgo_main.T1, align 8 br label %_llgo_16 @@ -999,7 +999,7 @@ _llgo_20: ; preds = %_llgo_19, %_llgo_18 br i1 %189, label %_llgo_21, label %_llgo_22 _llgo_21: ; preds = %_llgo_20 - %190 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 14, i64 1, i64 1) + %190 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 14, i64 8, i64 1, i64 1) store ptr %190, ptr @_llgo_main.T2, align 8 br label %_llgo_22 @@ -1099,7 +1099,7 @@ _llgo_28: ; preds = %_llgo_27, %_llgo_26 br i1 %238, label %_llgo_29, label %_llgo_30 _llgo_29: ; preds = %_llgo_28 - %239 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 3, i64 0, i64 1) + %239 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 3, i64 1, i64 0, i64 1) store ptr %239, ptr @_llgo_main.T3, align 8 br label %_llgo_30 @@ -1178,7 +1178,7 @@ _llgo_36: ; preds = %_llgo_35, %_llgo_34 br i1 %274, label %_llgo_37, label %_llgo_38 _llgo_37: ; preds = %_llgo_36 - %275 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 1, i64 1) + %275 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 8, i64 1, i64 1) store ptr %275, ptr @_llgo_main.T4, align 8 br label %_llgo_38 @@ -1280,7 +1280,7 @@ _llgo_44: ; preds = %_llgo_43, %_llgo_42 br i1 %325, label %_llgo_45, label %_llgo_46 _llgo_45: ; preds = %_llgo_44 - %326 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 1) + %326 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 8, i64 1, i64 1) store ptr %326, ptr @_llgo_main.T5, align 8 br label %_llgo_46 @@ -1403,7 +1403,7 @@ _llgo_50: ; preds = %_llgo_49, %_llgo_48 br i1 %393, label %_llgo_51, label %_llgo_52 _llgo_51: ; preds = %_llgo_50 - %394 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 1) + %394 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 24, i64 1, i64 1) store ptr %394, ptr @_llgo_main.T6, align 8 br label %_llgo_52 @@ -1723,7 +1723,7 @@ _llgo_66: ; preds = %_llgo_65, %_llgo_64 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/reader/out.ll b/cl/_testgo/reader/out.ll index 3422a840c..f4ff7db70 100644 --- a/cl/_testgo/reader/out.ll +++ b/cl/_testgo/reader/out.ll @@ -1552,7 +1552,7 @@ _llgo_21: ; preds = %_llgo_20 br label %_llgo_22 _llgo_22: ; preds = %_llgo_21, %_llgo_20 - %180 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 3, i64 3) + %180 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 3, i64 3) store ptr %180, ptr @_llgo_main.nopCloserWriterTo, align 8 %181 = load ptr, ptr @"_llgo_func$06yPPin-fnDnxFKkLLcJ1GEUhIobjPimde7T_Id_hmY", align 8 %182 = load ptr, ptr @"_llgo_struct$_3ow4zXXILqvC0WDqDRNq5DPhjE1DInJgN924VHWc2Y", align 8 @@ -1849,7 +1849,7 @@ _llgo_27: ; preds = %_llgo_26 br label %_llgo_28 _llgo_28: ; preds = %_llgo_27, %_llgo_26 - %361 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 2, i64 2) + %361 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 2, i64 2) store ptr %361, ptr @_llgo_main.nopCloser, align 8 %362 = load ptr, ptr @"_llgo_struct$_3ow4zXXILqvC0WDqDRNq5DPhjE1DInJgN924VHWc2Y", align 8 %363 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 @@ -2075,7 +2075,7 @@ _llgo_33: ; preds = %_llgo_32 br label %_llgo_34 _llgo_34: ; preds = %_llgo_33, %_llgo_32 - %496 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 10) + %496 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 32, i64 0, i64 10) store ptr %496, ptr @_llgo_main.stringReader, align 8 %497 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %498 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %497, i32 0, i32 0 @@ -2643,7 +2643,7 @@ _llgo_51: ; preds = %_llgo_50 br label %_llgo_52 _llgo_52: ; preds = %_llgo_51, %_llgo_50 - %830 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 1) + %830 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 0, i64 1) store ptr %830, ptr @_llgo_main.errorString, align 8 %831 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %832 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %831, i32 0, i32 0 @@ -2790,7 +2790,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr) declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testgo/struczero/out.ll b/cl/_testgo/struczero/out.ll index 59ced727c..9734ceb14 100644 --- a/cl/_testgo/struczero/out.ll +++ b/cl/_testgo/struczero/out.ll @@ -192,7 +192,7 @@ _llgo_0: br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 1) + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 1, i64 1) store ptr %2, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo", align 8 br label %_llgo_2 @@ -262,7 +262,7 @@ _llgo_3: ; preds = %_llgo_2 br i1 %43, label %_llgo_5, label %_llgo_6 _llgo_4: ; preds = %_llgo_10, %_llgo_2 - %44 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + %44 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 16, i64 0, i64 0) store ptr %44, ptr @_llgo_main.bar, align 8 %45 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %46 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %45, i32 0, i32 0 @@ -439,7 +439,7 @@ _llgo_10: ; preds = %_llgo_9, %_llgo_8 br label %_llgo_4 } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testrt/abinamed/out.ll b/cl/_testrt/abinamed/out.ll index c83b1d942..9a8c87a9c 100644 --- a/cl/_testrt/abinamed/out.ll +++ b/cl/_testrt/abinamed/out.ll @@ -445,7 +445,7 @@ _llgo_0: br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 48, i64 0, i64 0) store ptr %2, ptr @_llgo_main.T, align 8 br label %_llgo_2 @@ -476,7 +476,7 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0 %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %17, i32 0, i32 1 store i64 0, ptr %19, align 4 %20 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %17, align 8 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 18) + %21 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 80, i64 0, i64 18) %22 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %21) %23 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %16, ptr %22, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %20, i1 false) %24 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 @@ -645,7 +645,7 @@ _llgo_11: ; preds = %_llgo_10 %118 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %116, i32 0, i32 1 store i64 0, ptr %118, align 4 %119 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %116, align 8 - %120 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 8, i64 0, i64 0) + %120 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 8, i64 1, i64 0, i64 0) %121 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %115, ptr %120, i64 20, %"github.com/goplus/llgo/internal/runtime.String" %119, i1 false) %122 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %123 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %122, i32 0, i32 0 @@ -938,7 +938,7 @@ _llgo_18: ; preds = %_llgo_17, %_llgo_16 br i1 %300, label %_llgo_19, label %_llgo_20 _llgo_19: ; preds = %_llgo_18 - %301 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 16) + %301 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 104, i64 0, i64 16) store ptr %301, ptr @"_llgo_github.com/goplus/llgo/internal/abi.ArrayType", align 8 br label %_llgo_20 @@ -1162,7 +1162,7 @@ _llgo_28: ; preds = %_llgo_27, %_llgo_26 br i1 %430, label %_llgo_29, label %_llgo_30 _llgo_29: ; preds = %_llgo_28 - %431 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 19) + %431 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 128, i64 0, i64 19) store ptr %431, ptr @"_llgo_github.com/goplus/llgo/internal/abi.FuncType", align 8 br label %_llgo_30 @@ -1429,7 +1429,7 @@ _llgo_36: ; preds = %_llgo_35, %_llgo_33 br i1 %592, label %_llgo_37, label %_llgo_38 _llgo_37: ; preds = %_llgo_36 - %593 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 18) + %593 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 120, i64 0, i64 18) store ptr %593, ptr @"_llgo_github.com/goplus/llgo/internal/abi.InterfaceType", align 8 br label %_llgo_38 @@ -1478,7 +1478,7 @@ _llgo_39: ; preds = %_llgo_38 %621 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %619, i32 0, i32 1 store i64 0, ptr %621, align 4 %622 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %619, align 8 - %623 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 3) + %623 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 24, i64 0, i64 3) %624 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %623) %625 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %618, ptr %624, i64 88, %"github.com/goplus/llgo/internal/runtime.String" %622, i1 false) %626 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 @@ -1697,7 +1697,7 @@ _llgo_42: ; preds = %_llgo_92, %_llgo_40 br i1 %758, label %_llgo_93, label %_llgo_94 _llgo_43: ; preds = %_llgo_41 - %759 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 7, i64 1, i64 1) + %759 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 7, i64 8, i64 1, i64 1) store ptr %759, ptr @"_llgo_github.com/goplus/llgo/internal/abi.Kind", align 8 br label %_llgo_44 @@ -1894,7 +1894,7 @@ _llgo_54: ; preds = %_llgo_53, %_llgo_48 br i1 %863, label %_llgo_55, label %_llgo_56 _llgo_55: ; preds = %_llgo_54 - %864 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 22) + %864 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 136, i64 0, i64 22) store ptr %864, ptr @"_llgo_github.com/goplus/llgo/internal/abi.MapType", align 8 br label %_llgo_56 @@ -2546,7 +2546,7 @@ _llgo_64: ; preds = %_llgo_63, %_llgo_61 br i1 %1276, label %_llgo_65, label %_llgo_66 _llgo_65: ; preds = %_llgo_64 - %1277 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 18) + %1277 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 120, i64 0, i64 18) store ptr %1277, ptr @"_llgo_github.com/goplus/llgo/internal/abi.StructType", align 8 br label %_llgo_66 @@ -2595,7 +2595,7 @@ _llgo_67: ; preds = %_llgo_66 %1305 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1303, i32 0, i32 1 store i64 0, ptr %1305, align 4 %1306 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1303, align 8 - %1307 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 2) + %1307 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 56, i64 0, i64 2) %1308 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %1307) %1309 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %1302, ptr %1308, i64 88, %"github.com/goplus/llgo/internal/runtime.String" %1306, i1 false) %1310 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 @@ -2933,7 +2933,7 @@ _llgo_70: ; preds = %_llgo_84, %_llgo_68 br i1 %1519, label %_llgo_85, label %_llgo_86 _llgo_71: ; preds = %_llgo_69 - %1520 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 2) + %1520 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 24, i64 0, i64 2) store ptr %1520, ptr @"_llgo_github.com/goplus/llgo/internal/abi.UncommonType", align 8 br label %_llgo_72 @@ -3047,7 +3047,7 @@ _llgo_76: ; preds = %_llgo_80, %_llgo_74 br i1 %1586, label %_llgo_81, label %_llgo_82 _llgo_77: ; preds = %_llgo_75 - %1587 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 3) + %1587 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 40, i64 0, i64 3) %1588 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %1587) store ptr %1588, ptr @"[]_llgo_github.com/goplus/llgo/internal/abi.Method", align 8 br label %_llgo_78 @@ -4539,7 +4539,7 @@ _llgo_104: ; preds = %_llgo_103, %_llgo_1 br label %_llgo_14 } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testrt/eface/out.ll b/cl/_testrt/eface/out.ll index 5b45fc89f..e1b6efb8b 100644 --- a/cl/_testrt/eface/out.ll +++ b/cl/_testrt/eface/out.ll @@ -720,7 +720,7 @@ _llgo_38: ; preds = %_llgo_37, %_llgo_36 br i1 %117, label %_llgo_39, label %_llgo_40 _llgo_39: ; preds = %_llgo_38 - %118 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 24, i64 0, i64 1) + %118 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 24, i64 16, i64 0, i64 1) store ptr %118, ptr @_llgo_main.T, align 8 br label %_llgo_40 @@ -794,6 +794,6 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplu declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testrt/makemap/out.ll b/cl/_testrt/makemap/out.ll index dd32c808c..1a23a4d07 100644 --- a/cl/_testrt/makemap/out.ll +++ b/cl/_testrt/makemap/out.ll @@ -1347,7 +1347,7 @@ _llgo_8: ; preds = %_llgo_7, %_llgo_6 br i1 %221, label %_llgo_9, label %_llgo_10 _llgo_9: ; preds = %_llgo_8 - %222 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 0, i64 0) + %222 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 8, i64 0, i64 0) store ptr %222, ptr @_llgo_main.N1, align 8 br label %_llgo_10 @@ -1399,7 +1399,7 @@ _llgo_16: ; preds = %_llgo_15, %_llgo_14 br i1 %241, label %_llgo_17, label %_llgo_18 _llgo_17: ; preds = %_llgo_16 - %242 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 0, i64 0) + %242 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 2, i64 0, i64 0) store ptr %242, ptr @_llgo_main.K, align 8 br label %_llgo_18 @@ -1409,7 +1409,7 @@ _llgo_18: ; preds = %_llgo_17, %_llgo_16 br i1 %244, label %_llgo_19, label %_llgo_20 _llgo_19: ; preds = %_llgo_18 - %245 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + %245 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 2, i64 0, i64 0) store ptr %245, ptr @_llgo_main.N, align 8 br label %_llgo_20 @@ -1519,7 +1519,7 @@ _llgo_26: ; preds = %_llgo_25, %_llgo_24 br i1 %302, label %_llgo_27, label %_llgo_28 _llgo_27: ; preds = %_llgo_26 - %303 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 0, i64 0) + %303 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 8, i64 0, i64 0) call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %303) store ptr %303, ptr @_llgo_main.K2, align 8 br label %_llgo_28 @@ -1744,7 +1744,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/go declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice") diff --git a/cl/_testrt/typed/out.ll b/cl/_testrt/typed/out.ll index 0c352b463..326ab29cc 100644 --- a/cl/_testrt/typed/out.ll +++ b/cl/_testrt/typed/out.ll @@ -186,7 +186,7 @@ _llgo_0: br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 24, i64 0, i64 0) + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 24, i64 16, i64 0, i64 0) store ptr %2, ptr @_llgo_main.T, align 8 br label %_llgo_2 @@ -226,7 +226,7 @@ _llgo_6: ; preds = %_llgo_5, %_llgo_4 br i1 %16, label %_llgo_7, label %_llgo_8 _llgo_7: ; preds = %_llgo_6 - %17 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 0, i64 0) + %17 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 17, i64 16, i64 0, i64 0) store ptr %17, ptr @_llgo_main.A, align 8 br label %_llgo_8 @@ -276,7 +276,7 @@ _llgo_14: ; preds = %_llgo_13, %_llgo_12 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64, i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) diff --git a/internal/runtime/z_face.go b/internal/runtime/z_face.go index dd496f701..a6f7e4dac 100644 --- a/internal/runtime/z_face.go +++ b/internal/runtime/z_face.go @@ -107,9 +107,9 @@ func hdrSizeOf(kind abi.Kind) uintptr { } // NewNamed returns an uninitialized named type. -func NewNamed(kind abi.Kind, methods, ptrMethods int) *Type { - ret := newUninitedNamed(kind, methods) - ret.PtrToThis_ = newUninitedNamed(abi.Pointer, ptrMethods) +func NewNamed(kind abi.Kind, size uintptr, methods, ptrMethods int) *Type { + ret := newUninitedNamed(kind, size, methods) + ret.PtrToThis_ = newUninitedNamed(abi.Pointer, pointerSize, ptrMethods) return ret } @@ -138,9 +138,10 @@ func InitNamed(ret *Type, pkgPath, name string, underlying *Type, methods, ptrMe ptr.TFlag |= abi.TFlagExtraStar } -func newUninitedNamed(kind abi.Kind, methods int) *Type { - size := hdrSizeOf(kind) + uncommonTypeHdrSize + uintptr(methods)*methodSize - ret := (*Type)(AllocU(size)) +func newUninitedNamed(kind abi.Kind, size uintptr, methods int) *Type { + allocSize := hdrSizeOf(kind) + uncommonTypeHdrSize + uintptr(methods)*methodSize + ret := (*Type)(AllocU(allocSize)) + ret.Size_ = size ret.Kind_ = uint8(kind) ret.TFlag = abi.TFlagUninited return ret @@ -164,6 +165,7 @@ func doInitNamed(ret *Type, pkgPath, fullName string, underlying *Type, methods ret.TFlag = tflag | abi.TFlagNamed | abi.TFlagUncommon ret.Str_ = fullName ret.Equal = underlying.Equal + ret.Size_ = underlying.Size_ n := len(methods) xcount := uint16(0) diff --git a/ssa/abitype.go b/ssa/abitype.go index 8dd2a9bd8..b80aced83 100644 --- a/ssa/abitype.go +++ b/ssa/abitype.go @@ -206,13 +206,19 @@ func (b Builder) abiNamed(t *types.Named) Expr { pkg := b.Pkg tunder := t.Underlying() kind := int(abi.UnderlyingKind(tunder)) + size := b.sizeof(tunder) numMethods, numPtrMethods := b.abiMethods(t) newNamed := pkg.rtFunc("NewNamed") - expr := b.Call(newNamed, b.Prog.Val(kind), b.Prog.Val(numMethods), b.Prog.Val(numPtrMethods)) + expr := b.Call(newNamed, b.Prog.Val(kind), b.Prog.IntVal(uint64(size), b.Prog.Uintptr()), b.Prog.Val(numMethods), b.Prog.Val(numPtrMethods)) b.Pkg.named[t] = expr return expr } +func (b Builder) sizeof(t types.Type) int64 { + sizes := (*goProgram)(b.Prog) + return sizes.Sizeof(t) +} + // func InitNamed(ret *Type, pkgPath, name string, underlying *Type, methods, ptrMethods []Method) func (b Builder) abiInitNamed(ret Expr, t *types.Named) func() Expr { under := b.abiType(t.Underlying())