From: Matthew Dempsky Date: Tue, 29 Dec 2020 08:44:28 +0000 (-0800) Subject: [dev.regabi] cmd/compile: remove workarounds for go/constant issues X-Git-Tag: go1.17beta1~1539^2~187 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=171fc6f22388cc8628b5590f42d46a7c57277428;p=gostls13.git [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 --- diff --git a/src/cmd/compile/internal/typecheck/const.go b/src/cmd/compile/internal/typecheck/const.go index e22b284e82..5259218ef9 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 e35cbcafa2..c287d76c43 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 546ddcba79..86277e69bd 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: