Merge pull request #252 from visualfc/fnnamed
ssa: fix llvm named in func
This commit is contained in:
@@ -6,6 +6,12 @@ import (
|
||||
"github.com/goplus/llgo/internal/abi"
|
||||
)
|
||||
|
||||
type T string
|
||||
|
||||
func (t *T) Invoke() {
|
||||
println("invoke")
|
||||
}
|
||||
|
||||
type eface struct {
|
||||
_type *abi.Type
|
||||
data unsafe.Pointer
|
||||
@@ -36,6 +42,8 @@ func main() {
|
||||
y int
|
||||
z int
|
||||
}{})
|
||||
var t T
|
||||
dump(t)
|
||||
}
|
||||
|
||||
func dump(v any) {
|
||||
@@ -45,5 +53,19 @@ func dump(v any) {
|
||||
|
||||
func dumpTyp(t *abi.Type, sep string) {
|
||||
print(sep)
|
||||
println(t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_)
|
||||
println(t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_, t.PtrToThis_, t.Uncommon())
|
||||
if t.Elem() != nil {
|
||||
dumpTyp(t.Elem(), sep+"\telem: ")
|
||||
}
|
||||
if t.Uncommon() != nil {
|
||||
dumpUncommon(t.Uncommon(), sep+"\tuncomm: ")
|
||||
if t.PtrToThis_ != nil {
|
||||
dumpUncommon(t.PtrToThis_.Uncommon(), sep+"\tuncomm: ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dumpUncommon(u *abi.UncommonType, sep string) {
|
||||
print(sep)
|
||||
println(u.PkgPath_, u.Mcount, u.Xcount)
|
||||
}
|
||||
@@ -1,15 +1,21 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%main.eface = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.Type" = type { i64, i64, i32, i8, i8, i8, i8, { ptr, ptr }, ptr, %"github.com/goplus/llgo/internal/runtime.String", ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.UncommonType" = type { %"github.com/goplus/llgo/internal/runtime.String", i16, i16, i32 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global ptr null
|
||||
@0 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@0 = private unnamed_addr constant [7 x i8] c"invoke\00", align 1
|
||||
@1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@2 = private unnamed_addr constant [8 x i8] c"\09elem: \00", align 1
|
||||
@3 = private unnamed_addr constant [10 x i8] c"\09uncomm: \00", align 1
|
||||
@4 = private unnamed_addr constant [10 x i8] c"\09uncomm: \00", align 1
|
||||
@__llgo_argc = global ptr null
|
||||
@__llgo_argv = global ptr null
|
||||
@_llgo_bool = linkonce global ptr null
|
||||
@@ -30,16 +36,34 @@ source_filename = "main"
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null
|
||||
@"*_llgo_int" = linkonce global ptr null
|
||||
@"[]_llgo_int" = linkonce global ptr null
|
||||
@1 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
|
||||
@5 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
|
||||
@_llgo_string = linkonce global ptr null
|
||||
@"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM" = global ptr null
|
||||
@2 = private unnamed_addr constant [2 x i8] c"x\00", align 1
|
||||
@3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@4 = private unnamed_addr constant [2 x i8] c"y\00", align 1
|
||||
@5 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@6 = private unnamed_addr constant [2 x i8] c"z\00", align 1
|
||||
@6 = private unnamed_addr constant [2 x i8] c"x\00", align 1
|
||||
@7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@8 = private unnamed_addr constant [5 x i8] c"main\00", align 1
|
||||
@8 = private unnamed_addr constant [2 x i8] c"y\00", align 1
|
||||
@9 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@10 = private unnamed_addr constant [2 x i8] c"z\00", align 1
|
||||
@11 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@12 = private unnamed_addr constant [5 x i8] c"main\00", align 1
|
||||
@13 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
@_llgo_main.T = linkonce global ptr null
|
||||
@14 = private unnamed_addr constant [7 x i8] c"Invoke\00", align 1
|
||||
@15 = private unnamed_addr constant [5 x i8] c"main\00", align 1
|
||||
@16 = private unnamed_addr constant [7 x i8] c"main.T\00", align 1
|
||||
|
||||
define void @"main.(*T).Invoke"(ptr %0) {
|
||||
_llgo_0:
|
||||
%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
|
||||
store ptr @0, ptr %2, align 8
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 1
|
||||
store i64 6, ptr %3, align 4
|
||||
%4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
@@ -49,7 +73,7 @@ _llgo_0:
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 0
|
||||
store ptr @0, ptr %5, align 8
|
||||
store ptr @1, ptr %5, align 8
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1
|
||||
store i64 0, ptr %6, align 4
|
||||
%7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8
|
||||
@@ -71,20 +95,98 @@ _llgo_0:
|
||||
%10 = load i8, ptr %9, align 1
|
||||
%11 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 4
|
||||
%12 = load i8, ptr %11, align 1
|
||||
%13 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%14 = load ptr, ptr %13, align 8
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %2)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %6)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%13 = zext i32 %8 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %13)
|
||||
%16 = zext i32 %8 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %16)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%14 = zext i8 %10 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %14)
|
||||
%17 = zext i8 %10 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%15 = zext i8 %12 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %15)
|
||||
%18 = zext i8 %12 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %18)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %14)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %15)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr %0)
|
||||
%20 = icmp ne ptr %19, null
|
||||
br i1 %20, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr %0)
|
||||
%22 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %22, i32 0, i32 0
|
||||
store ptr @2, ptr %23, align 8
|
||||
%24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %22, i32 0, i32 1
|
||||
store i64 7, ptr %24, align 4
|
||||
%25 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %22, align 8
|
||||
%26 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" %25)
|
||||
call void @main.dumpTyp(ptr %21, %"github.com/goplus/llgo/internal/runtime.String" %26)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%27 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
%28 = icmp ne ptr %27, null
|
||||
br i1 %28, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%29 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
%30 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %30, i32 0, i32 0
|
||||
store ptr @3, ptr %31, align 8
|
||||
%32 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %30, i32 0, i32 1
|
||||
store i64 9, ptr %32, align 4
|
||||
%33 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %30, align 8
|
||||
%34 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" %33)
|
||||
call void @main.dumpUncommon(ptr %29, %"github.com/goplus/llgo/internal/runtime.String" %34)
|
||||
%35 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%36 = load ptr, ptr %35, align 8
|
||||
%37 = icmp ne ptr %36, null
|
||||
br i1 %37, label %_llgo_5, label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_5, %_llgo_3, %_llgo_2
|
||||
ret void
|
||||
|
||||
_llgo_5: ; preds = %_llgo_3
|
||||
%38 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%39 = load ptr, ptr %38, align 8
|
||||
%40 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %39)
|
||||
%41 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 0
|
||||
store ptr @4, ptr %42, align 8
|
||||
%43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 1
|
||||
store i64 9, ptr %43, align 4
|
||||
%44 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8
|
||||
%45 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" %44)
|
||||
call void @main.dumpUncommon(ptr %40, %"github.com/goplus/llgo/internal/runtime.String" %45)
|
||||
br label %_llgo_4
|
||||
}
|
||||
|
||||
define void @main.dumpUncommon(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
||||
%2 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8
|
||||
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 1
|
||||
%5 = load i16, ptr %4, align 2
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 2
|
||||
%7 = load i16, ptr %6, align 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%8 = zext i16 %5 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%9 = zext i16 %7 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
@@ -269,7 +371,7 @@ _llgo_0:
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %99)
|
||||
%100 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 0
|
||||
store ptr @1, ptr %101, align 8
|
||||
store ptr @5, ptr %101, align 8
|
||||
%102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 1
|
||||
store i64 5, ptr %102, align 4
|
||||
%103 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %100, align 8
|
||||
@@ -293,18 +395,42 @@ _llgo_0:
|
||||
store ptr %111, ptr %114, align 8
|
||||
%115 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %112, align 8
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %115)
|
||||
%116 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%117 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %116, i32 0, i32 0
|
||||
store ptr @13, ptr %117, align 8
|
||||
%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 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%121 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %119, ptr %121, align 8
|
||||
%122 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
|
||||
%123 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %122, i32 0, i32 0
|
||||
store ptr %120, ptr %123, align 8
|
||||
%124 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %122, i32 0, i32 1
|
||||
store ptr %121, ptr %124, align 8
|
||||
%125 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %122, align 8
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %125)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/abi.(*Type).Kind"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/abi.init"()
|
||||
|
||||
@@ -528,46 +654,46 @@ _llgo_38: ; preds = %_llgo_37, %_llgo_36
|
||||
%74 = load ptr, ptr @_llgo_int, align 8
|
||||
%75 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 0
|
||||
store ptr @2, ptr %76, align 8
|
||||
store ptr @6, ptr %76, align 8
|
||||
%77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 1
|
||||
store i64 1, ptr %77, align 4
|
||||
%78 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %75, align 8
|
||||
%79 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%80 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %79, i32 0, i32 0
|
||||
store ptr @3, ptr %80, align 8
|
||||
store ptr @7, ptr %80, align 8
|
||||
%81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %79, i32 0, i32 1
|
||||
store i64 0, ptr %81, align 4
|
||||
%82 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %79, align 8
|
||||
%83 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %78, ptr %72, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %82, i1 false)
|
||||
%84 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %84, i32 0, i32 0
|
||||
store ptr @4, ptr %85, align 8
|
||||
store ptr @8, ptr %85, align 8
|
||||
%86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %84, i32 0, i32 1
|
||||
store i64 1, ptr %86, align 4
|
||||
%87 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %84, align 8
|
||||
%88 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 0
|
||||
store ptr @5, ptr %89, align 8
|
||||
store ptr @9, ptr %89, align 8
|
||||
%90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 1
|
||||
store i64 0, ptr %90, align 4
|
||||
%91 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %88, align 8
|
||||
%92 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %87, ptr %73, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %91, i1 false)
|
||||
%93 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%94 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 0
|
||||
store ptr @6, ptr %94, align 8
|
||||
store ptr @10, ptr %94, align 8
|
||||
%95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 1
|
||||
store i64 1, ptr %95, align 4
|
||||
%96 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %93, align 8
|
||||
%97 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%98 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %97, i32 0, i32 0
|
||||
store ptr @7, ptr %98, align 8
|
||||
store ptr @11, ptr %98, align 8
|
||||
%99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %97, i32 0, i32 1
|
||||
store i64 0, ptr %99, align 4
|
||||
%100 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %97, align 8
|
||||
%101 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %96, ptr %74, i64 16, %"github.com/goplus/llgo/internal/runtime.String" %100, i1 false)
|
||||
%102 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%103 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %102, i32 0, i32 0
|
||||
store ptr @8, ptr %103, align 8
|
||||
store ptr @12, ptr %103, align 8
|
||||
%104 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %102, i32 0, i32 1
|
||||
store i64 4, ptr %104, align 4
|
||||
%105 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %102, align 8
|
||||
@@ -588,6 +714,64 @@ _llgo_38: ; preds = %_llgo_37, %_llgo_36
|
||||
%114 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %110, align 8
|
||||
%115 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %105, i64 24, %"github.com/goplus/llgo/internal/runtime.Slice" %114)
|
||||
store ptr %115, ptr @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM", align 8
|
||||
%116 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%117 = icmp eq ptr %116, null
|
||||
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)
|
||||
store ptr %118, ptr @_llgo_main.T, align 8
|
||||
br label %_llgo_40
|
||||
|
||||
_llgo_40: ; preds = %_llgo_39, %_llgo_38
|
||||
%119 = load ptr, ptr @_llgo_string, align 8
|
||||
br i1 %117, label %_llgo_41, label %_llgo_42
|
||||
|
||||
_llgo_41: ; preds = %_llgo_40
|
||||
%120 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%121 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %120, i32 0, i32 0
|
||||
store ptr @14, ptr %121, align 8
|
||||
%122 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %120, i32 0, i32 1
|
||||
store i64 6, ptr %122, align 4
|
||||
%123 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %120, align 8
|
||||
%124 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%125 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8
|
||||
%126 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %125, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %123, ptr %126, align 8
|
||||
%127 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %125, i32 0, i32 1
|
||||
store ptr %124, ptr %127, align 8
|
||||
%128 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %125, i32 0, i32 2
|
||||
store ptr @"main.(*T).Invoke", ptr %128, align 8
|
||||
%129 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %125, i32 0, i32 3
|
||||
store ptr @"main.(*T).Invoke", ptr %129, align 8
|
||||
%130 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %125, align 8
|
||||
%131 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%132 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %131, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %130, ptr %132, align 8
|
||||
%133 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
||||
%134 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 0
|
||||
store ptr %131, ptr %134, align 8
|
||||
%135 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 1
|
||||
store i64 1, ptr %135, align 4
|
||||
%136 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 2
|
||||
store i64 1, ptr %136, align 4
|
||||
%137 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, align 8
|
||||
%138 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%139 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %138, i32 0, i32 0
|
||||
store ptr @15, ptr %139, align 8
|
||||
%140 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %138, i32 0, i32 1
|
||||
store i64 4, ptr %140, align 4
|
||||
%141 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %138, align 8
|
||||
%142 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%143 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %142, i32 0, i32 0
|
||||
store ptr @16, ptr %143, align 8
|
||||
%144 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %142, i32 0, i32 1
|
||||
store i64 6, ptr %144, align 4
|
||||
%145 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %142, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %118, %"github.com/goplus/llgo/internal/runtime.String" %141, %"github.com/goplus/llgo/internal/runtime.String" %145, ptr %119, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %137)
|
||||
br label %_llgo_42
|
||||
|
||||
_llgo_42: ; preds = %_llgo_41, %_llgo_40
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -611,3 +795,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr)
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
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 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")
|
||||
Binary file not shown.
@@ -112,7 +112,8 @@ type aProgram struct {
|
||||
target *Target
|
||||
td llvm.TargetData
|
||||
// tm llvm.TargetMachine
|
||||
named map[string]llvm.Type
|
||||
named map[string]llvm.Type
|
||||
fnnamed map[string]int
|
||||
|
||||
intType llvm.Type
|
||||
int1Type llvm.Type
|
||||
@@ -195,7 +196,7 @@ func NewProgram(target *Target) Program {
|
||||
return &aProgram{
|
||||
ctx: ctx, gocvt: newGoTypes(),
|
||||
target: target, td: td, is32Bits: is32Bits,
|
||||
ptrSize: td.PointerSize(), named: make(map[string]llvm.Type),
|
||||
ptrSize: td.PointerSize(), named: make(map[string]llvm.Type), fnnamed: make(map[string]int),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
ssa/type.go
12
ssa/type.go
@@ -451,10 +451,20 @@ func (p Program) retType(raw *types.Signature) Type {
|
||||
}
|
||||
}
|
||||
|
||||
func (p Program) llvmNameOf(named *types.Named) (name string) {
|
||||
name = NameOf(named)
|
||||
if obj := named.Obj(); obj != nil && obj.Parent() != nil && obj.Parent() != obj.Pkg().Scope() {
|
||||
index := p.fnnamed[name]
|
||||
p.fnnamed[name] = index + 1
|
||||
name += fmt.Sprintf("#%v", index)
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (p Program) toNamed(raw *types.Named) Type {
|
||||
switch t := raw.Underlying().(type) {
|
||||
case *types.Struct:
|
||||
name := NameOf(raw)
|
||||
name := p.llvmNameOf(raw)
|
||||
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkStruct}
|
||||
default:
|
||||
typ := p.rawType(t)
|
||||
|
||||
@@ -26,14 +26,12 @@ import (
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type goTypes struct {
|
||||
typs map[unsafe.Pointer]unsafe.Pointer
|
||||
named map[string]*types.Named
|
||||
typs map[unsafe.Pointer]unsafe.Pointer
|
||||
}
|
||||
|
||||
func newGoTypes() goTypes {
|
||||
typs := make(map[unsafe.Pointer]unsafe.Pointer)
|
||||
named := make(map[string]*types.Named)
|
||||
return goTypes{typs, named}
|
||||
return goTypes{typs}
|
||||
}
|
||||
|
||||
type Background int
|
||||
@@ -118,14 +116,6 @@ func (p goTypes) cvtNamed(t *types.Named) (raw *types.Named, cvt bool) {
|
||||
cvt = t != raw
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
p.typs[unsafe.Pointer(t)] = unsafe.Pointer(raw)
|
||||
}()
|
||||
id := t.String()
|
||||
if named, ok := p.named[id]; ok {
|
||||
return named, false
|
||||
}
|
||||
|
||||
n := t.NumMethods()
|
||||
methods := make([]*types.Func, n)
|
||||
for i := 0; i < n; i++ {
|
||||
@@ -133,8 +123,7 @@ func (p goTypes) cvtNamed(t *types.Named) (raw *types.Named, cvt bool) {
|
||||
methods[i] = m
|
||||
}
|
||||
named := types.NewNamed(t.Obj(), types.Typ[types.Int], methods)
|
||||
p.named[id] = named
|
||||
defer delete(p.named, id)
|
||||
p.typs[unsafe.Pointer(t)] = unsafe.Pointer(named)
|
||||
if tund, cvt := p.cvtType(t.Underlying()); cvt {
|
||||
named.SetUnderlying(tund)
|
||||
return named, true
|
||||
|
||||
Reference in New Issue
Block a user