• Josh Bleecher Snyder's avatar
    cmd/compile: fix pos of typenames created during SSA construction · 165a96e2
    Josh Bleecher Snyder authored
    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: default avatarMatthew Dempsky <mdempsky@google.com>
    165a96e2
ssa.go 152 KB