]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix pos of typenames created during SSA construction
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Mar 2017 02:00:14 +0000 (19:00 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Mar 2017 04:14:26 +0000 (04:14 +0000)
commit165a96e28131b703a1d318da245285bd98546bf6
tree48d97198bb825cf55204b0247ad429f6774899bf
parent67a46cc1636362bea54ab68b521f77a778968ea2
cmd/compile: fix pos of typenames created during SSA construction

Prior to this CL, the function's position was used.
The dottype Node's position is clearly better.

I'm not thrilled about introducing a reference to
lineno in the middle of SSA construction;
I will have to remove it later.
My immediate goal is stability and correctness of positions,
though, since that aids refactoring, so this is an improvement.

An example from package io:

func (t *multiWriter) WriteString(s string) (n int, err error) {
var p []byte // lazily initialized if/when needed
for _, w := range t.writers {
if sw, ok := w.(stringWriter); ok {
n, err = sw.WriteString(s)

The w.(stringWriter) type assertion includes loading
the address of static type data for stringWriter:

LEAQ type."".stringWriter(SB), R10

Prior to this CL, this instruction was given the line number
of the function declaration.
After this CL, this instruction is given the line number
of the type assertion itself.

Change-Id: Ifcca274b581a5a57d7e3102c4d7b7786bf307210
Reviewed-on: https://go-review.googlesource.com/38389
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/ssa.go