]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: remove workarounds for go/constant issues
authorMatthew Dempsky <mdempsky@google.com>
Tue, 29 Dec 2020 08:44:28 +0000 (00:44 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 29 Dec 2020 09:12:55 +0000 (09:12 +0000)
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>

src/cmd/compile/internal/typecheck/const.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go

index e22b284e829d2c7057579aa8bd6e136987c80dab..5259218ef91cbc4b3bf0c46150bcb43ee608b822 100644 (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 {
index e35cbcafa25e532166a8dd47df2d31732fc73fb9..c287d76c4370f628adf55c0a27bdce6202a3d2a5 100644 (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)
        }
index 546ddcba79295f3775de49b84600a79c3fac3b52..86277e69bd4cc9a4193f4777787284fac1b5d735 100644 (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: