From: Matthew Dempsky Date: Fri, 1 Jan 2021 10:23:48 +0000 (-0800) Subject: [dev.regabi] cmd/compile: simplify dwarfgen.declPos X-Git-Tag: go1.17beta1~1539^2~156 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7d55669847;p=gostls13.git [dev.regabi] cmd/compile: simplify dwarfgen.declPos The previous code was way overcomplicating things. To find out if a variable is a closure pseudo-variable, one only needs to check IsClosureVar. Checking Captured and Byval are only meant to be used by closure conversion. Passes toolstash -cmp. Change-Id: I22622cba36ba7f60b3275d17999a8b6bb7c6719a Reviewed-on: https://go-review.googlesource.com/c/go/+/280995 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky Reviewed-by: Cuong Manh Le TryBot-Result: Go Bot --- diff --git a/src/cmd/compile/internal/dwarfgen/dwarf.go b/src/cmd/compile/internal/dwarfgen/dwarf.go index 42c83b1f23..6eac9d547e 100644 --- a/src/cmd/compile/internal/dwarfgen/dwarf.go +++ b/src/cmd/compile/internal/dwarfgen/dwarf.go @@ -127,22 +127,8 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope, } func declPos(decl *ir.Name) src.XPos { - if decl.Defn != nil && (decl.Captured() || decl.Byval()) { - // It's not clear which position is correct for captured variables here: - // * decl.Pos is the wrong position for captured variables, in the inner - // function, but it is the right position in the outer function. - // * decl.Name.Defn is nil for captured variables that were arguments - // on the outer function, however the decl.Pos for those seems to be - // correct. - // * decl.Name.Defn is the "wrong" thing for variables declared in the - // header of a type switch, it's their position in the header, rather - // than the position of the case statement. In principle this is the - // right thing, but here we prefer the latter because it makes each - // instance of the header variable local to the lexical block of its - // case statement. - // This code is probably wrong for type switch variables that are also - // captured. - return decl.Defn.Pos() + if decl.IsClosureVar() { + decl = decl.Defn.(*ir.Name) } return decl.Pos() }