aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-05-10 10:17:51 -0700
committerDan Scales <danscales@google.com>2021-05-21 17:14:19 +0000
commitb1a398cf0f04ac911be204d3c0ee001a94621683 (patch)
tree46dc3881562f151d261423b87b60f19ef51c816f /src/cmd/compile
parentccbfbb1c3327fffe88dd6b6da550f4a0cd37db6e (diff)
downloadgo-b1a398cf0f04ac911be204d3c0ee001a94621683.tar.gz
go-b1a398cf0f04ac911be204d3c0ee001a94621683.zip
[dev.typeparams] cmd/compile: add import/export of calls to builtin functions
For generic functions, we have to leave the builtins in OCALL form, rather than transform to specific ops, since we don't know the exact types involved. Allow export/import of builtins in OCALL form. Added new export/import test mapimp.go. Change-Id: I571f8eeaa13b4f69389dbdb9afb6cc61924b9bf2 Reviewed-on: https://go-review.googlesource.com/c/go/+/321750 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/typecheck/iexport.go10
-rw-r--r--src/cmd/compile/internal/typecheck/iimport.go4
2 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go
index d125dadd88..802a8c3839 100644
--- a/src/cmd/compile/internal/typecheck/iexport.go
+++ b/src/cmd/compile/internal/typecheck/iexport.go
@@ -1579,6 +1579,16 @@ func (w *exportWriter) expr(n ir.Node) {
// We don't need a type here, as the type will be provided at the
// declaration of n.
w.op(ir.ONAME)
+
+ // This handles the case where we haven't yet transformed a call
+ // to a builtin, so we must write out the builtin as a name in the
+ // builtin package.
+ isBuiltin := n.BuiltinOp != ir.OXXX
+ w.bool(isBuiltin)
+ if isBuiltin {
+ w.string(n.Sym().Name)
+ break
+ }
w.localName(n)
// case OPACK, ONONAME:
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go
index 3b725a226c..39b5ab09da 100644
--- a/src/cmd/compile/internal/typecheck/iimport.go
+++ b/src/cmd/compile/internal/typecheck/iimport.go
@@ -1184,6 +1184,10 @@ func (r *importReader) node() ir.Node {
return n
case ir.ONAME:
+ isBuiltin := r.bool()
+ if isBuiltin {
+ return types.BuiltinPkg.Lookup(r.string()).Def.(*ir.Name)
+ }
return r.localName()
// case OPACK, ONONAME: