From a4451e11437c2375c7451d90aac5419903629b16 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Sat, 4 Apr 2020 22:51:15 +0100 Subject: [PATCH] cmd/compile: print block auxint value in HTML output The auxint value was being printed in LongString() but not LongHTML(). Fixes #38250. Change-Id: I28e819feef8710f912bee424d1b900eb07f3abb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/227160 Run-TryBot: Michael Munday TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/cmd/compile/internal/ssa/block.go | 24 +++++++++++++++--------- src/cmd/compile/internal/ssa/html.go | 3 +++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go index c1a734b20b..fedbc7af0e 100644 --- a/src/cmd/compile/internal/ssa/block.go +++ b/src/cmd/compile/internal/ssa/block.go @@ -124,15 +124,8 @@ func (b *Block) LongString() string { if b.Aux != nil { s += fmt.Sprintf(" {%s}", b.Aux) } - if t := b.Kind.AuxIntType(); t != "" { - switch t { - case "Int8": - s += fmt.Sprintf(" [%v]", int8(b.AuxInt)) - case "UInt8": - s += fmt.Sprintf(" [%v]", uint8(b.AuxInt)) - default: - s += fmt.Sprintf(" [%v]", b.AuxInt) - } + if t := b.AuxIntString(); t != "" { + s += fmt.Sprintf(" [%s]", t) } for _, c := range b.ControlValues() { s += fmt.Sprintf(" %s", c) @@ -341,6 +334,19 @@ func (b *Block) LackingPos() bool { return true } +func (b *Block) AuxIntString() string { + switch b.Kind.AuxIntType() { + case "Int8": + return fmt.Sprintf("%v", int8(b.AuxInt)) + case "UInt8": + return fmt.Sprintf("%v", uint8(b.AuxInt)) + default: // type specified but not implemented - print as int64 + return fmt.Sprintf("%v", b.AuxInt) + case "": // no aux int type + return "" + } +} + func (b *Block) Logf(msg string, args ...interface{}) { b.Func.Logf(msg, args...) } func (b *Block) Log() bool { return b.Func.Log() } func (b *Block) Fatalf(msg string, args ...interface{}) { b.Func.Fatalf(msg, args...) } diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go index f39106f450..730ec6dd3f 100644 --- a/src/cmd/compile/internal/ssa/html.go +++ b/src/cmd/compile/internal/ssa/html.go @@ -1005,6 +1005,9 @@ func (b *Block) LongHTML() string { if b.Aux != nil { s += html.EscapeString(fmt.Sprintf(" {%v}", b.Aux)) } + if t := b.AuxIntString(); t != "" { + s += html.EscapeString(fmt.Sprintf(" [%v]", t)) + } for _, c := range b.ControlValues() { s += fmt.Sprintf(" %s", c.HTML()) } -- 2.50.0