go.tools/ssa: extend debug information to arbitrary ast.Exprs.

CanonicalPos was inadequate since many pairs of instruction share the same pos (e.g. Allocs and Phis).  Instead, we generalize the DebugRef instruction to associate not just Idents but Exprs with ssa.Values.

We no longer store any DebugRefs for constant expressions, to save space.  (The type and value of such expressions can be obtained by other means, at a cost in complexity.)

Function.ValueForExpr queries the DebugRef info to return the ssa.Value of a given Expr.

Added tests.

Also:
- the DebugInfo flag is now per package, not global.
   It must be set between Create and Build phases if desired.
- {Value,Instruction}.Pos() documentation updated: we still maintain
  this information in the instruction stream even in non-debug mode,
  but we make fewer claims about its invariants.
- Go and Defer instructions can now use their respective go/defer
   token positions (not the call's lparen), so they do.
- SelectState:
     Posn token.Pos indicates the <- position
     DebugNode ast.Expr is the send stmt or receive expr.
- In building SelectStmt, we introduce extra temporaries in debug
   mode to hold the result of the receive in 'case <-ch' even though
   this value isn't ordinarily needed.
- Use *SelectState (indirectly) since the struct is getting bigger.
- Document some missing instructions in doc.go.

R=gri
CC=golang-dev
https://golang.org/cl/12147043
diff --git a/ssa/lvalue.go b/ssa/lvalue.go
index c205666..3c49948 100644
--- a/ssa/lvalue.go
+++ b/ssa/lvalue.go
@@ -25,7 +25,7 @@
 type address struct {
 	addr    Value
 	starPos token.Pos    // source position, if from explicit *addr
-	id      *ast.Ident   // source syntax, if from *ast.Ident
+	expr    ast.Expr     // source syntax [debug mode]
 	object  types.Object // source var, if from *ast.Ident
 }
 
@@ -38,16 +38,16 @@
 func (a *address) store(fn *Function, v Value) {
 	store := emitStore(fn, a.addr, v)
 	store.pos = a.starPos
-	if a.id != nil {
+	if a.expr != nil {
 		// store.Val is v converted for assignability.
-		emitDebugRef(fn, a.id, store.Val)
+		emitDebugRef(fn, a.expr, store.Val)
 	}
 }
 
 func (a *address) address(fn *Function) Value {
-	if a.id != nil {
+	if a.expr != nil {
 		// NB: this kind of DebugRef yields the object's address.
-		emitDebugRef(fn, a.id, a.addr)
+		emitDebugRef(fn, a.expr, a.addr)
 	}
 	return a.addr
 }