Skip to content

Commit 38d9fa2

Browse files
committed
ssa: detect needAbiInit moved into builder.call
1 parent 8bf439e commit 38d9fa2

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

ssa/decl.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,11 @@ func (p Package) NewFunc(name string, sig *types.Signature, bg Background) Funct
198198
return p.NewFuncEx(name, sig, bg, false, false)
199199
}
200200

201-
type none struct{}
202-
203-
var (
204-
reflectFunc = map[string]none{
205-
"reflect.ArrayOf": none{},
206-
"reflect.ChanOf": none{},
207-
"reflect.FuncOf": none{},
208-
"reflect.MapOf": none{},
209-
"reflect.SliceOf": none{},
210-
"reflect.StructOf": none{},
211-
}
212-
)
213-
214201
// NewFuncEx creates a new function.
215202
func (p Package) NewFuncEx(name string, sig *types.Signature, bg Background, hasFreeVars bool, instantiated bool) Function {
216203
if v, ok := p.fns[name]; ok {
217204
return v
218205
}
219-
if !p.NeedAbiInit && p.Path() != "reflect" {
220-
if _, ok := reflectFunc[name]; ok {
221-
p.NeedAbiInit = true
222-
}
223-
}
224206
t := p.Prog.FuncDecl(sig, bg)
225207
if debugInstr {
226208
log.Println("NewFunc", name, t.raw.Type, "hasFreeVars:", hasFreeVars)

ssa/expr.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,30 @@ func (b Builder) Call(fn Expr, args ...Expr) (ret Expr) {
10551055
default:
10561056
log.Panicf("unreachable: %d(%T), %v\n", kind, raw, fn.RawType())
10571057
}
1058+
pkg := b.Pkg
1059+
if !pkg.NeedAbiInit && pkg.Path() != "reflect" {
1060+
if _, ok := reflectFunc[fn.Name()]; ok {
1061+
pkg.NeedAbiInit = true
1062+
}
1063+
}
10581064
ret.Type = b.Prog.retType(sig)
10591065
ret.impl = llvm.CreateCall(b.impl, ll, fn.impl, llvmParamsEx(data, args, sig.Params(), b))
10601066
return
10611067
}
10621068

1069+
var (
1070+
reflectFunc = map[string]struct{}{
1071+
"reflect.ArrayOf": {},
1072+
"reflect.ChanOf": {},
1073+
"reflect.FuncOf": {},
1074+
"reflect.MapOf": {},
1075+
"reflect.SliceOf": {},
1076+
"reflect.StructOf": {},
1077+
"reflect.Value.Method": {},
1078+
"reflect.Value.MethodByName": {},
1079+
}
1080+
)
1081+
10631082
func logCall(da string, fn Expr, args []Expr) {
10641083
if fn.kind == vkBuiltin {
10651084
return

0 commit comments

Comments
 (0)