From 171fc6f22388cc8628b5590f42d46a7c57277428 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 29 Dec 2020 00:44:28 -0800 Subject: [PATCH] [dev.regabi] cmd/compile: remove workarounds for go/constant issues These were fixed in CLs 273086 and 273126, which have been merged back into dev.regabi already. Passes toolstash -cmp. Change-Id: I011e9ed7062bc034496a279e21cc163267bf83fd Reviewed-on: https://go-review.googlesource.com/c/go/+/280643 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky Reviewed-by: Cuong Manh Le TryBot-Result: Go Bot --- src/cmd/compile/internal/typecheck/const.go | 11 +---------- src/cmd/compile/internal/typecheck/iexport.go | 2 +- src/cmd/compile/internal/typecheck/iimport.go | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/const.go b/src/cmd/compile/internal/typecheck/const.go index e22b284e829..5259218ef91 100644 --- a/src/cmd/compile/internal/typecheck/const.go +++ b/src/cmd/compile/internal/typecheck/const.go @@ -564,20 +564,11 @@ func EvalConst(n ir.Node) ir.Node { return n } -func makeInt(i *big.Int) constant.Value { - if i.IsInt64() { - return constant.Make(i.Int64()) // workaround #42640 (Int64Val(Make(big.NewInt(10))) returns (10, false), not (10, true)) - } - return constant.Make(i) -} - func makeFloat64(f float64) constant.Value { if math.IsInf(f, 0) { base.Fatalf("infinity is not a valid constant") } - v := constant.MakeFloat64(f) - v = constant.ToFloat(v) // workaround #42641 (MakeFloat64(0).Kind() returns Int, not Float) - return v + return constant.MakeFloat64(f) } func makeComplex(real, imag constant.Value) constant.Value { diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index e35cbcafa25..c287d76c437 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -936,7 +936,7 @@ func (w *exportWriter) mpfloat(v constant.Value, typ *types.Type) { if acc != big.Exact { base.Fatalf("mantissa scaling failed for %f (%s)", f, acc) } - w.mpint(makeInt(manti), typ) + w.mpint(constant.Make(manti), typ) if manti.Sign() != 0 { w.int64(exp) } diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 546ddcba792..86277e69bd4 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -372,7 +372,7 @@ func (p *importReader) value(typ *types.Type) constant.Value { case constant.Int: var i big.Int p.mpint(&i, typ) - return makeInt(&i) + return constant.Make(&i) case constant.Float: return p.float(typ) case constant.Complex: