From 8c30971da654a37a5f5f211e6dccf8d83e7ee463 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 20 Mar 2020 19:08:13 +0000 Subject: [PATCH] cmd/compile: panic if trying to alias an intrinsic with no definitions 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall Reviewed-by: Cherry Zhang --- src/cmd/compile/internal/gc/ssa.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 76832ca829..c813807e09 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -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 ********/ -- 2.50.0