Commit 0b8c0767 authored by Robert Griesemer's avatar Robert Griesemer

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/22441Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent e48a2958
......@@ -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
}
......
......@@ -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()
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment