Skip to content

Commit

Permalink
cmd/compile: make sure alg functions are generated when we call them
Browse files Browse the repository at this point in the history
When DWARF is disabled, some alg functions were not generated.
Make sure they are generated when we about to generate calls to
them.

Fixes golang#23546.

Change-Id: Iecfa0eea830e42ee92e55268167cefb1540980b2
Reviewed-on: https://go-review.googlesource.com/122403
Run-TryBot: Cherry Zhang <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Josh Bleecher Snyder <[email protected]>
  • Loading branch information
cherrymui committed Jul 10, 2018
1 parent 5f256dc commit c801232
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,12 @@ func typesymprefix(prefix string, t *types.Type) *types.Sym {
p := prefix + "." + t.ShortString()
s := typeLookup(p)

// This function is for looking up type-related generated functions
// (e.g. eq and hash). Make sure they are indeed generated.
signatsetmu.Lock()
addsignat(t)
signatsetmu.Unlock()

//print("algsym: %s -> %+S\n", p, s);

return s
Expand Down
4 changes: 0 additions & 4 deletions test/fixedbugs/issue23545.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build gccgo

// Issue 23545: gccgo didn't lower array comparison to
// proper equality function in some case.
// TODO: build only on gccgo for now, as it hits issue
// #23546.

package main

Expand Down
22 changes: 22 additions & 0 deletions test/fixedbugs/issue23546.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// run

// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Issue 23546: type..eq function not generated when
// DWARF is disabled.

package main

func main() {
use(f() == f())
}

func f() [2]interface{} {
var out [2]interface{}
return out
}

//go:noinline
func use(bool) {}

0 comments on commit c801232

Please sign in to comment.