diff options
author | Dmitri Shuralyov <dmitshur@google.com> | 2022-08-01 15:54:13 +0000 |
---|---|---|
committer | Dmitri Shuralyov <dmitshur@google.com> | 2022-08-01 15:54:13 +0000 |
commit | 349da2d42d3193af7f54170ae842166e4571134a (patch) | |
tree | a0b59dc2dfa4440add9d954efe1908272933247a /src/cmd/compile/internal | |
parent | 7d5078e3bf2d865526e8ec2d211f61b2fac2936f (diff) | |
parent | 15da892a4950a4caac987ee72c632436329f62d5 (diff) | |
download | go-dev.boringcrypto.go1.17.tar.gz go-dev.boringcrypto.go1.17.zip |
[dev.boringcrypto.go1.17] all: merge go1.17.13 into dev.boringcrypto.go1.17dev.boringcrypto.go1.17
Change-Id: Iaf4f2cb506aab9e22a5df5b937c38fc108f1e1c1
Diffstat (limited to 'src/cmd/compile/internal')
-rw-r--r-- | src/cmd/compile/internal/ssa/loopbce.go | 7 | ||||
-rw-r--r-- | src/cmd/compile/internal/walk/complit.go | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/loopbce.go b/src/cmd/compile/internal/ssa/loopbce.go index 5a4bc1d60a..fd03efb417 100644 --- a/src/cmd/compile/internal/ssa/loopbce.go +++ b/src/cmd/compile/internal/ssa/loopbce.go @@ -159,6 +159,13 @@ func findIndVar(f *Func) []indVar { step = -step } + if flags&indVarMaxInc != 0 && max.Op == OpConst64 && max.AuxInt+step < max.AuxInt { + // For a <= comparison, we need to make sure that a value equal to + // max can be incremented without overflowing. + // (For a < comparison, the %step check below ensures no overflow.) + continue + } + // Up to now we extracted the induction variable (ind), // the increment delta (inc), the temporary sum (nxt), // the mininum value (min) and the maximum value (max). diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go index abd920d646..1f288d21c1 100644 --- a/src/cmd/compile/internal/walk/complit.go +++ b/src/cmd/compile/internal/walk/complit.go @@ -621,6 +621,12 @@ func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool { // not a special composite literal assignment return false } + if x.Addrtaken() { + // If x is address-taken, the RHS may (implicitly) uses LHS. + // Not safe to do a special composite literal assignment + // (which may expand to multiple assignments). + return false + } switch n.Y.Op() { default: @@ -629,7 +635,7 @@ func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool { case ir.OSTRUCTLIT, ir.OARRAYLIT, ir.OSLICELIT, ir.OMAPLIT: if ir.Any(n.Y, func(y ir.Node) bool { return ir.Uses(y, x) }) { - // not a special composite literal assignment + // not safe to do a special composite literal assignment if RHS uses LHS. return false } anylit(n.Y, n.X, init) |