1
0
mirror of https://github.com/golang/go synced 2024-11-12 06:20:22 -07:00

cmd/compile: for now, keep parameter numbering in binary export format

The numbering is only required for parameters of functions/methods
with exported inlineable bodies. For now, always export parameter names
with internal numbering to minimize the diffs between assembly code
dumps of code compiled with the textual vs the binary format.

To be disabled again once the new export format is default.

Change-Id: I6d14c564e734cc5596c7e995d8851e06d5a35013
Reviewed-on: https://go-review.googlesource.com/22441
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-04-25 14:39:51 -07:00
parent e48a2958d1
commit 0b8c0767d0
2 changed files with 12 additions and 1 deletions

View File

@ -123,6 +123,13 @@ const posInfoFormat = false
// TODO(gri) remove eventually
const forceNewExport = false // force new export format - DO NOT SUBMIT with this flag set
// forceNumberedParams keeps parameter numbering in exported parameter names
// even where we don't really need it (because the parameter names are not used
// elsewhere). Leave it enabled for now to remove this difference in generated
// object files so we can more easily compare old and new format.
// TODO(gri) remove once we switched to new format
const forceNumberedParams = true
const exportVersion = "v0"
// exportInlined enables the export of inlined function bodies and related
@ -875,7 +882,7 @@ func parName(f *Field, numbered bool) string {
// Functions that can be inlined use numbered parameters so we can distingish them
// from other names in their context after inlining (i.e., the parameter numbering
// is a form of parameter rewriting). See issue 4326 for an example and test case.
if numbered {
if forceNumberedParams || numbered {
if !strings.Contains(name, "·") && f.Nname != nil && f.Nname.Name != nil && f.Nname.Name.Vargen > 0 {
name = fmt.Sprintf("%s·%d", name, f.Nname.Name.Vargen) // append Vargen
}

View File

@ -11,6 +11,7 @@ import (
"go/token"
"go/types"
"sort"
"strings"
"unicode"
"unicode/utf8"
)
@ -504,6 +505,9 @@ func (p *importer) param(named bool) (*types.Var, bool) {
if name == "" {
panic("expected named parameter")
}
if i := strings.Index(name, "·"); i > 0 {
name = name[:i] // cut off gc-specific parameter numbering
}
pkg = p.pkg()
}