Skip to content

Commit e2421ae

Browse files
Merge branch 'golang:master' into master
2 parents d811922 + d61c0c9 commit e2421ae

File tree

48 files changed

+850
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+850
-207
lines changed

src/bufio/bufio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030

3131
// Reader implements buffering for an io.Reader object.
3232
// A new Reader is created by calling [NewReader] or [NewReaderSize];
33-
// alternatively the zero value of a Reader may be used after calling [Reset]
33+
// alternatively the zero value of a Reader may be used after calling [Reader.Reset]
3434
// on it.
3535
type Reader struct {
3636
buf []byte

src/cmd/compile/internal/ssa/prove.go

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,29 +2180,56 @@ func (ft *factsTable) detectSubRelations(v *Value) {
21802180

21812181
// Check if we might wrap around. If so, give up.
21822182
width := uint(v.Type.Size()) * 8
2183-
if _, ok := safeSub(xLim.min, yLim.max, width); !ok {
2184-
return // x-y might underflow
2185-
}
2186-
if _, ok := safeSub(xLim.max, yLim.min, width); !ok {
2187-
return // x-y might overflow
2183+
2184+
// v >= 1 in the signed domain?
2185+
var vSignedMinOne bool
2186+
2187+
// Signed optimizations
2188+
if _, ok := safeSub(xLim.min, yLim.max, width); ok {
2189+
// Large abs negative y can also overflow
2190+
if _, ok := safeSub(xLim.max, yLim.min, width); ok {
2191+
// x-y won't overflow
2192+
2193+
// Subtracting a positive non-zero number only makes
2194+
// things smaller. If it's positive or zero, it might
2195+
// also do nothing (x-0 == v).
2196+
if yLim.min > 0 {
2197+
ft.update(v.Block, v, x, signed, lt)
2198+
} else if yLim.min == 0 {
2199+
ft.update(v.Block, v, x, signed, lt|eq)
2200+
}
2201+
2202+
// Subtracting a number from a bigger one
2203+
// can't go below 1. If the numbers might be
2204+
// equal, then it can't go below 0.
2205+
//
2206+
// This requires the overflow checks because
2207+
// large negative y can cause an overflow.
2208+
if ft.orderS.Ordered(y, x) {
2209+
ft.signedMin(v, 1)
2210+
vSignedMinOne = true
2211+
} else if ft.orderS.OrderedOrEqual(y, x) {
2212+
ft.setNonNegative(v)
2213+
}
2214+
}
21882215
}
21892216

2190-
// Subtracting a positive non-zero number only makes
2191-
// things smaller. If it's positive or zero, it might
2192-
// also do nothing (x-0 == v).
2193-
if yLim.min > 0 {
2194-
ft.update(v.Block, v, x, signed, lt)
2195-
} else if yLim.min == 0 {
2196-
ft.update(v.Block, v, x, signed, lt|eq)
2217+
// Unsigned optimizations
2218+
if _, ok := safeSubU(xLim.umin, yLim.umax, width); ok {
2219+
if yLim.umin > 0 {
2220+
ft.update(v.Block, v, x, unsigned, lt)
2221+
} else {
2222+
ft.update(v.Block, v, x, unsigned, lt|eq)
2223+
}
21972224
}
21982225

2199-
// Subtracting a number from a bigger one
2200-
// can't go below 1. If the numbers might be
2201-
// equal, then it can't go below 0.
2202-
if ft.orderS.Ordered(y, x) {
2203-
ft.signedMin(v, 1)
2204-
} else if ft.orderS.OrderedOrEqual(y, x) {
2205-
ft.setNonNegative(v)
2226+
// Proving v >= 1 in the signed domain automatically
2227+
// proves it in the unsigned domain, so we can skip it.
2228+
//
2229+
// We don't need overflow checks here, since if y < x,
2230+
// then x-y can never overflow for uint.
2231+
if !vSignedMinOne && ft.orderU.Ordered(y, x) {
2232+
ft.unsignedMin(v, 1)
22062233
}
22072234
}
22082235

src/cmd/compile/internal/ssagen/intrinsics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ func findIntrinsic(sym *types.Sym) intrinsicBuilder {
21702170

21712171
fn := sym.Name
21722172
if ssa.IntrinsicsDisable {
2173-
if pkg == "internal/runtime/sys" && (fn == "GetCallerPC" || fn == "GrtCallerSP" || fn == "GetClosurePtr") ||
2173+
if pkg == "internal/runtime/sys" && (fn == "GetCallerPC" || fn == "GetCallerSP" || fn == "GetClosurePtr") ||
21742174
pkg == simdPackage {
21752175
// These runtime functions don't have definitions, must be intrinsics.
21762176
} else {

src/cmd/compile/internal/types/type.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,9 @@ func (t *Type) SetUnderlying(underlying *Type) {
16831683
if underlying.HasShape() {
16841684
t.SetHasShape(true)
16851685
}
1686+
if underlying.isSIMD {
1687+
simdify(t, underlying.isSIMDTag)
1688+
}
16861689

16871690
// spec: "The declared type does not inherit any methods bound
16881691
// to the existing type, but the method set of an interface

src/cmd/compile/internal/walk/range.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
348348
// } else {
349349
// hv2, hv1 = decoderune(ha, hv1)
350350
fn := typecheck.LookupRuntime("decoderune")
351+
// decoderune expects a uint, but hv1 is an int.
352+
// This is safe because hv1 is always >= 0.
351353
call := mkcall1(fn, fn.Type().ResultsTuple(), &nif.Else, ha, hv1)
352354
a := ir.NewAssignListStmt(base.Pos, ir.OAS2, []ir.Node{hv2, hv1}, []ir.Node{call})
353355
nif.Else.Append(a)

src/cmd/cover/cover_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,12 @@ func main() {
638638
t.Errorf("unexpected success; want failure due to newline in file path")
639639
}
640640
}
641+
642+
func TestAlignment(t *testing.T) {
643+
// Test that cover data structures are aligned appropriately. See issue 58936.
644+
testenv.MustHaveGoRun(t)
645+
t.Parallel()
646+
647+
cmd := testenv.Command(t, testenv.GoToolPath(t), "test", "-cover", filepath.Join(testdata, "align.go"), filepath.Join(testdata, "align_test.go"))
648+
run(cmd, t)
649+
}

src/cmd/cover/testdata/align.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2026 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
var badSlice [8265]byte
8+
9+
func init() {
10+
badSlice[0] = 4
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2026 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
import "testing"
8+
9+
func TestFoo(t *testing.T) {
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[!cgo] skip
2+
3+
# Test that -g3 works with cgo.
4+
env CGO_CFLAGS=-g3
5+
go build
6+
7+
-- go.mod --
8+
module cgog3
9+
10+
go 1.25
11+
-- m.go --
12+
package main
13+
14+
import "os/user"
15+
16+
func main() {
17+
user.Current()
18+
}

src/cmd/internal/sys/arch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var ArchLoong64 = &Arch{
143143
PtrSize: 8,
144144
RegSize: 8,
145145
MinLC: 4,
146-
Alignment: 8, // Unaligned accesses are not guaranteed to be fast
146+
Alignment: 1,
147147
CanMergeLoads: true,
148148
CanJumpTable: true,
149149
HasLR: true,

0 commit comments

Comments
 (0)