[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 <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2020-12-29 00:44:28 -08:00
parent 33801cdc62
commit 171fc6f223
3 changed files with 3 additions and 12 deletions

View file

@ -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 {

View file

@ -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)
}

View file

@ -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: