cl: funcName check $bound
This commit is contained in:
@@ -319,7 +319,7 @@ _llgo_17: ; preds = %_llgo_4
|
||||
%108 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
%109 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %108, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %43, ptr %109, align 8
|
||||
%110 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound", ptr undef }, ptr %108, 1
|
||||
%110 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound", ptr undef }, ptr %108, 1
|
||||
%111 = extractvalue { ptr, ptr } %110, 1
|
||||
%112 = extractvalue { ptr, ptr } %110, 0
|
||||
%113 = call i64 %112(ptr %111)
|
||||
@@ -339,7 +339,7 @@ _llgo_19: ; preds = %_llgo_6
|
||||
%119 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
%120 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %119, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %51, ptr %120, align 8
|
||||
%121 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound", ptr undef }, ptr %119, 1
|
||||
%121 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound", ptr undef }, ptr %119, 1
|
||||
%122 = extractvalue { ptr, ptr } %121, 1
|
||||
%123 = extractvalue { ptr, ptr } %121, 0
|
||||
%124 = call i64 %123(ptr %122)
|
||||
@@ -359,7 +359,7 @@ _llgo_21: ; preds = %_llgo_12
|
||||
%130 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
%131 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %130, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %93, ptr %131, align 8
|
||||
%132 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound", ptr undef }, ptr %130, 1
|
||||
%132 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound", ptr undef }, ptr %130, 1
|
||||
%133 = extractvalue { ptr, ptr } %132, 1
|
||||
%134 = extractvalue { ptr, ptr } %132, 0
|
||||
%135 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %134(ptr %133)
|
||||
@@ -380,7 +380,7 @@ _llgo_23: ; preds = %_llgo_14
|
||||
%142 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
%143 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %142, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %101, ptr %143, align 8
|
||||
%144 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound", ptr undef }, ptr %142, 1
|
||||
%144 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound", ptr undef }, ptr %142, 1
|
||||
%145 = extractvalue { ptr, ptr } %144, 1
|
||||
%146 = extractvalue { ptr, ptr } %144, 0
|
||||
%147 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %146(ptr %145)
|
||||
@@ -585,7 +585,7 @@ declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamedInterface"
|
||||
|
||||
declare void @"github.com/goplus/llgo/runtime/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/runtime/internal/runtime.Slice")
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound"(ptr %0) {
|
||||
define i64 @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
||||
@@ -603,7 +603,7 @@ _llgo_0:
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/runtime/internal/runtime.StringEqual"(%"github.com/goplus/llgo/runtime/internal/runtime.String", %"github.com/goplus/llgo/runtime/internal/runtime.String")
|
||||
|
||||
define %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound"(ptr %0) {
|
||||
define %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
||||
|
||||
25
cl/_testrt/closurebound/in.go
Normal file
25
cl/_testrt/closurebound/in.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
se := demo1{}
|
||||
f := se.encode
|
||||
if f() != 1 {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
var my = demo2{}.encode
|
||||
|
||||
type demo1 struct {
|
||||
}
|
||||
|
||||
func (se demo1) encode() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
type demo2 struct {
|
||||
}
|
||||
|
||||
func (se demo2) encode() int {
|
||||
return 2
|
||||
}
|
||||
117
cl/_testrt/closurebound/out.ll
Normal file
117
cl/_testrt/closurebound/out.ll
Normal file
@@ -0,0 +1,117 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testrt/closurebound'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testrt/closurebound"
|
||||
|
||||
%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" = type {}
|
||||
%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" = type {}
|
||||
%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testrt/closurebound.init$guard" = global i1 false, align 1
|
||||
@"github.com/goplus/llgo/cl/_testrt/closurebound.my" = global { ptr, ptr } zeroinitializer, align 8
|
||||
@0 = private unnamed_addr constant [5 x i8] c"error", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %0) {
|
||||
_llgo_0:
|
||||
ret i64 1
|
||||
}
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.(*demo1).encode"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1", ptr %0, align 1
|
||||
%2 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %1)
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %0) {
|
||||
_llgo_0:
|
||||
ret i64 2
|
||||
}
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.(*demo2).encode"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2", ptr %0, align 1
|
||||
%2 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %1)
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/cl/_testrt/closurebound.init$after"()
|
||||
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||
%2 = getelementptr inbounds { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" }, ptr %1, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" zeroinitializer, ptr %2, align 1
|
||||
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode$bound", ptr undef }, ptr %1, 1
|
||||
store { ptr, ptr } %3, ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.my", align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.main"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||
%1 = getelementptr inbounds { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" }, ptr %0, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" zeroinitializer, ptr %1, align 1
|
||||
%2 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode$bound", ptr undef }, ptr %0, 1
|
||||
%3 = extractvalue { ptr, ptr } %2, 1
|
||||
%4 = extractvalue { ptr, ptr } %2, 0
|
||||
%5 = call i64 %4(ptr %3)
|
||||
%6 = icmp ne i64 %5, 1
|
||||
br i1 %6, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%7 = load ptr, ptr @_llgo_string, align 8
|
||||
%8 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 5 }, ptr %8, align 8
|
||||
%9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %7, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %9, ptr %8, 1
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %10)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" }, ptr %0, align 1
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" } %1, 0
|
||||
%3 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" }, ptr %0, align 1
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" } %1, 0
|
||||
%3 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_string, align 8
|
||||
%1 = icmp eq ptr %0, null
|
||||
br i1 %1, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%2 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 24)
|
||||
store ptr %2, ptr @_llgo_string, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface")
|
||||
@@ -29,7 +29,7 @@ _llgo_0:
|
||||
%3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
||||
store ptr %1, ptr %4, align 8
|
||||
%5 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound", ptr undef }, ptr %3, 1
|
||||
%5 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound", ptr undef }, ptr %3, 1
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/closureconv.Call", ptr %1, i32 0, i32 0
|
||||
%7 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
||||
store { ptr, ptr } %5, ptr %7, align 8
|
||||
@@ -46,7 +46,7 @@ _llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||
%2 = getelementptr inbounds { ptr }, ptr %1, i32 0, i32 0
|
||||
store ptr %0, ptr %2, align 8
|
||||
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound", ptr undef }, ptr %1, 1
|
||||
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound", ptr undef }, ptr %1, 1
|
||||
%4 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
||||
store { ptr, ptr } %3, ptr %4, align 8
|
||||
%5 = load %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", ptr %4, align 8
|
||||
@@ -158,7 +158,7 @@ _llgo_0:
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound"(ptr %0, i64 %1, i64 %2) {
|
||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = load { ptr }, ptr %0, align 8
|
||||
%4 = extractvalue { ptr } %3, 0
|
||||
|
||||
@@ -124,7 +124,7 @@ _llgo_6: ; preds = %_llgo_4
|
||||
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||
%33 = getelementptr inbounds { ptr }, ptr %32, i32 0, i32 0
|
||||
store ptr %30, ptr %33, align 8
|
||||
%34 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.next$bound", ptr undef }, ptr %32, 1
|
||||
%34 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound", ptr undef }, ptr %32, 1
|
||||
%35 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } %34)
|
||||
%36 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
|
||||
br label %_llgo_7
|
||||
@@ -182,7 +182,7 @@ declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
||||
|
||||
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.next$bound"(ptr %0) {
|
||||
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
|
||||
@@ -402,6 +402,10 @@ func funcName(pkg *types.Package, fn *ssa.Function, org bool) string {
|
||||
recv = parent.Signature.Recv()
|
||||
} else {
|
||||
recv = fn.Signature.Recv()
|
||||
// check $bound
|
||||
if recv == nil && strings.HasSuffix(fn.Name(), "$bound") && len(fn.FreeVars) == 1 {
|
||||
recv = types.NewVar(token.NoPos, nil, "", fn.FreeVars[0].Type())
|
||||
}
|
||||
}
|
||||
var fnName string
|
||||
if org := fn.Origin(); org != nil {
|
||||
|
||||
Reference in New Issue
Block a user