Description

A DebugRef instruction maps a source-level expression Expr to the SSA value X that represents the value (!IsAddr) or address (IsAddr) of that expression.

DebugRef is a pseudo-instruction: it has no dynamic effect.

Pos() returns Expr.Pos(), the start position of the source-level expression. This is not the same as the "designated" token as documented at Value.Pos(). e.g. CallExpr.Pos() does not return the position of the ("designated") Lparen token.

If Expr is an *ast.Ident denoting a var or func, Object() returns the object; though this information can be obtained from the type checker, including it here greatly facilitates debugging. For non-Ident expressions, Object() returns nil.

DebugRefs are generated only for functions built with debugging enabled; see Package.SetDebugMode() and the GlobalDebug builder mode flag.

DebugRefs are not emitted for ast.Idents referring to constants or predeclared identifiers, since they are trivial and numerous. Nor are they emitted for ast.ParenExprs.

(By representing these as instructions, rather than out-of-band, consistency is maintained during transformation passes by the ordinary SSA renaming machinery.)

Example printed form:

; *ast.CallExpr @ 102:9 is t5
; var x float64 @ 109:72 is x
; address of *ast.CompositeLit @ 216:10 is t0