Skip to content

Commit

Permalink
ssa: fix map key has typeargs
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Sep 15, 2024
1 parent a1572d5 commit fa0c2cf
Show file tree
Hide file tree
Showing 6 changed files with 916 additions and 112 deletions.
223 changes: 115 additions & 108 deletions cl/_testrt/makemap/out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1087,158 +1087,165 @@ _llgo_0:
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1
store i64 5, ptr %6, align 4
%7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8
%8 = load ptr, ptr @_llgo_main.M, align 8
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %9, align 4
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %8, ptr %3, ptr %9)
store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %10, align 8
%8 = load ptr, ptr @_llgo_int, align 8
%9 = load ptr, ptr @_llgo_string, align 8
%10 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
%11 = load ptr, ptr @_llgo_main.M, align 8
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %11, ptr %3)
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %12, align 4
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %11, ptr %3, ptr %12)
store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %13, align 8
%14 = load ptr, ptr @_llgo_main.M, align 8
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %14, ptr %3)
br label %_llgo_1

_llgo_1: ; preds = %_llgo_2, %_llgo_0
%13 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %12)
%14 = extractvalue { i1, ptr, ptr } %13, 0
br i1 %14, label %_llgo_4, label %_llgo_5
%16 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %15)
%17 = extractvalue { i1, ptr, ptr } %16, 0
br i1 %17, label %_llgo_4, label %_llgo_5

_llgo_2: ; preds = %_llgo_6
%15 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %31, 1
%16 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %31, 2
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %15)
%18 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %34, 1
%19 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %34, 2
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %18)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %16)
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %19)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
br label %_llgo_1

_llgo_3: ; preds = %_llgo_6
ret void

_llgo_4: ; preds = %_llgo_1
%17 = extractvalue { i1, ptr, ptr } %13, 1
%18 = extractvalue { i1, ptr, ptr } %13, 2
%19 = load i64, ptr %17, align 4
%20 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %18, align 8
%21 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%22 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %21, i32 0, i32 0
store i1 true, ptr %22, align 1
%23 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %21, i32 0, i32 1
store i64 %19, ptr %23, align 4
%24 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %21, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" %20, ptr %24, align 8
%25 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %21, align 8
%20 = extractvalue { i1, ptr, ptr } %16, 1
%21 = extractvalue { i1, ptr, ptr } %16, 2
%22 = load i64, ptr %20, align 4
%23 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %21, align 8
%24 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%25 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %24, i32 0, i32 0
store i1 true, ptr %25, align 1
%26 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %24, i32 0, i32 1
store i64 %22, ptr %26, align 4
%27 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %24, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" %23, ptr %27, align 8
%28 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %24, align 8
br label %_llgo_6

_llgo_5: ; preds = %_llgo_1
%26 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%27 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %26, i32 0, i32 0
store i1 false, ptr %27, align 1
%28 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %26, i32 0, i32 1
store i64 0, ptr %28, align 4
%29 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %26, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, ptr %29, align 8
%30 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %26, align 8
%29 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%30 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %29, i32 0, i32 0
store i1 false, ptr %30, align 1
%31 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %29, i32 0, i32 1
store i64 0, ptr %31, align 4
%32 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %29, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, ptr %32, align 8
%33 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %29, align 8
br label %_llgo_6

_llgo_6: ; preds = %_llgo_5, %_llgo_4
%31 = phi { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } [ %25, %_llgo_4 ], [ %30, %_llgo_5 ]
%32 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %31, 0
br i1 %32, label %_llgo_2, label %_llgo_3
%34 = phi { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } [ %28, %_llgo_4 ], [ %33, %_llgo_5 ]
%35 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %34, 0
br i1 %35, label %_llgo_2, label %_llgo_3
}

define void @main.make7() {
_llgo_0:
%0 = load ptr, ptr @_llgo_main.N, align 8
%1 = load ptr, ptr @_llgo_string, align 8
%2 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %2, i64 2)
%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 @5, ptr %5, align 8
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1
store i64 5, ptr %6, align 4
%7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8
%8 = load ptr, ptr @_llgo_main.N, align 8
%9 = load ptr, ptr @_llgo_string, align 8
%10 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %11, align 4
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %10, ptr %3, ptr %11)
store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %12, align 8
%13 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 0
store ptr @6, ptr %14, align 8
%15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 1
store i64 5, ptr %15, align 4
%16 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %13, align 8
%17 = load ptr, ptr @_llgo_main.N, align 8
%18 = load ptr, ptr @_llgo_string, align 8
%19 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 2, ptr %20, align 4
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %19, ptr %3, ptr %20)
store %"github.com/goplus/llgo/internal/runtime.String" %16, ptr %21, align 8
%22 = load ptr, ptr @_llgo_main.N, align 8
%23 = load ptr, ptr @_llgo_string, align 8
%24 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %24, ptr %3)
%0 = load ptr, ptr @_llgo_int, align 8
%1 = load ptr, ptr @_llgo_main.N, align 8
%2 = load ptr, ptr @_llgo_string, align 8
%3 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %3, i64 2)
%5 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 0
store ptr @5, ptr %6, align 8
%7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 1
store i64 5, ptr %7, align 4
%8 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %5, align 8
%9 = load ptr, ptr @_llgo_int, align 8
%10 = load ptr, ptr @_llgo_main.N, align 8
%11 = load ptr, ptr @_llgo_string, align 8
%12 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %13, align 4
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %12, ptr %4, ptr %13)
store %"github.com/goplus/llgo/internal/runtime.String" %8, ptr %14, align 8
%15 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 0
store ptr @6, ptr %16, align 8
%17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 1
store i64 5, ptr %17, align 4
%18 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %15, align 8
%19 = load ptr, ptr @_llgo_int, align 8
%20 = load ptr, ptr @_llgo_main.N, align 8
%21 = load ptr, ptr @_llgo_string, align 8
%22 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 2, ptr %23, align 4
%24 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %22, ptr %4, ptr %23)
store %"github.com/goplus/llgo/internal/runtime.String" %18, ptr %24, align 8
%25 = load ptr, ptr @_llgo_main.N, align 8
%26 = load ptr, ptr @_llgo_string, align 8
%27 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.NewMapIter"(ptr %27, ptr %4)
br label %_llgo_1

_llgo_1: ; preds = %_llgo_2, %_llgo_0
%26 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %25)
%27 = extractvalue { i1, ptr, ptr } %26, 0
br i1 %27, label %_llgo_4, label %_llgo_5
%29 = call { i1, ptr, ptr } @"github.com/goplus/llgo/internal/runtime.MapIterNext"(ptr %28)
%30 = extractvalue { i1, ptr, ptr } %29, 0
br i1 %30, label %_llgo_4, label %_llgo_5

_llgo_2: ; preds = %_llgo_6
%28 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %50, 1
%29 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %50, 2
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %28)
%31 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %54, 1
%32 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %54, 2
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %31)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %29)
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %32)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
br label %_llgo_1

_llgo_3: ; preds = %_llgo_6
%30 = load ptr, ptr @_llgo_main.N, align 8
%31 = load ptr, ptr @_llgo_string, align 8
%32 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %33, align 4
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAccess1"(ptr %32, ptr %3, ptr %33)
%35 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %34, align 8
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %35)
%33 = load ptr, ptr @_llgo_int, align 8
%34 = load ptr, ptr @_llgo_main.N, align 8
%35 = load ptr, ptr @_llgo_string, align 8
%36 = load ptr, ptr @"map[_llgo_main.N]_llgo_string", align 8
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
store i64 1, ptr %37, align 4
%38 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAccess1"(ptr %36, ptr %4, ptr %37)
%39 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %38, align 8
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %39)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
ret void

_llgo_4: ; preds = %_llgo_1
%36 = extractvalue { i1, ptr, ptr } %26, 1
%37 = extractvalue { i1, ptr, ptr } %26, 2
%38 = load i64, ptr %36, align 4
%39 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8
%40 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%41 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %40, i32 0, i32 0
store i1 true, ptr %41, align 1
%42 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %40, i32 0, i32 1
store i64 %38, ptr %42, align 4
%43 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %40, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" %39, ptr %43, align 8
%44 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %40, align 8
%40 = extractvalue { i1, ptr, ptr } %29, 1
%41 = extractvalue { i1, ptr, ptr } %29, 2
%42 = load i64, ptr %40, align 4
%43 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8
%44 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%45 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %44, i32 0, i32 0
store i1 true, ptr %45, align 1
%46 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %44, i32 0, i32 1
store i64 %42, ptr %46, align 4
%47 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %44, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" %43, ptr %47, align 8
%48 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %44, align 8
br label %_llgo_6

_llgo_5: ; preds = %_llgo_1
%45 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%46 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %45, i32 0, i32 0
store i1 false, ptr %46, align 1
%47 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %45, i32 0, i32 1
store i64 0, ptr %47, align 4
%48 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %45, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, ptr %48, align 8
%49 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %45, align 8
%49 = alloca { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, align 8
%50 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %49, i32 0, i32 0
store i1 false, ptr %50, align 1
%51 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %49, i32 0, i32 1
store i64 0, ptr %51, align 4
%52 = getelementptr inbounds { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %49, i32 0, i32 2
store %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, ptr %52, align 8
%53 = load { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %49, align 8
br label %_llgo_6

_llgo_6: ; preds = %_llgo_5, %_llgo_4
%50 = phi { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } [ %44, %_llgo_4 ], [ %49, %_llgo_5 ]
%51 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %50, 0
br i1 %51, label %_llgo_2, label %_llgo_3
%54 = phi { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } [ %48, %_llgo_4 ], [ %53, %_llgo_5 ]
%55 = extractvalue { i1, i64, %"github.com/goplus/llgo/internal/runtime.String" } %54, 0
br i1 %55, label %_llgo_2, label %_llgo_3
}

declare void @"github.com/goplus/llgo/internal/runtime.init"()
Expand Down
26 changes: 26 additions & 0 deletions cl/_testrt/tpmap/in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

type T1 int

type T2 struct {
v int
}

type T3[T any] struct {
v T
}

type cacheKey struct {
t1 T1
t2 T2
t3 T3[any]
t4 *int
t5 uintptr
}

func main() {
m := map[cacheKey]string{}
m[cacheKey{0, T2{0}, T3[any]{0}, nil, 0}] = "world"
v, ok := m[cacheKey{0, T2{0}, T3[any]{0}, nil, 0}]
println(v, ok)
}
Loading

0 comments on commit fa0c2cf

Please sign in to comment.