]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: panic if trying to alias an intrinsic with no definitions
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 20 Mar 2020 19:08:13 +0000 (19:08 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 23 Mar 2020 16:01:20 +0000 (16:01 +0000)
Currently if we try to alias an intrinsic which hasn't been defined for
any architecture (such as by accidentally creating the alias before the
intrinsic is created with addF), then we'll just silently not apply any
intrinsics to those aliases.

Catch this particular case by panicking in alias if we try to apply the
alias and it did nothing.

Change-Id: I98e75fc3f7206b08fc9267cedb8db3e109ec4f5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/224637
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go

index 76832ca82988c1e3d457737696c69f0716e0fe95..c813807e09ee1a603f442a2134efad1529d14701 100644 (file)
@@ -3251,11 +3251,16 @@ func init() {
        }
        // alias defines pkg.fn = pkg2.fn2 for all architectures in archs for which pkg2.fn2 exists.
        alias := func(pkg, fn, pkg2, fn2 string, archs ...*sys.Arch) {
+               aliased := false
                for _, a := range archs {
                        if b, ok := intrinsics[intrinsicKey{a, pkg2, fn2}]; ok {
                                intrinsics[intrinsicKey{a, pkg, fn}] = b
+                               aliased = true
                        }
                }
+               if !aliased {
+                       panic(fmt.Sprintf("attempted to alias undefined intrinsic: %s.%s", pkg, fn))
+               }
        }
 
        /******** runtime ********/