Skip to content

Commit 0a644bd

Browse files
committed
Merge branch 'master' into feature/internal-msan
2 parents 517d50d + 1c9c9c8 commit 0a644bd

File tree

221 files changed

+2927
-3289
lines changed

Some content is hidden

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

221 files changed

+2927
-3289
lines changed

doc/next/7-ports.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
## Ports {#ports}
22

3+
### Darwin {#darwin}
4+
5+
<!-- go.dev/issue/64207 -->
6+
As [announced](go1.22#darwin) in the Go 1.22 release notes,
7+
Go 1.23 requires macOS 11 Big Sur or later;
8+
support for previous versions has been discontinued.

src/cmd/cgo/internal/testsanitizers/cc_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import (
1616
"encoding/json"
1717
"errors"
1818
"fmt"
19+
"internal/testenv"
1920
"os"
2021
"os/exec"
22+
"os/user"
2123
"path/filepath"
2224
"regexp"
2325
"strconv"
@@ -266,12 +268,28 @@ func compilerSupportsLocation() bool {
266268
case "gcc":
267269
return compiler.major >= 10
268270
case "clang":
271+
// TODO(65606): The clang toolchain on the LUCI builders is not built against
272+
// zlib, the ASAN runtime can't actually symbolize its own stack trace. Once
273+
// this is resolved, one way or another, switch this back to 'true'. We still
274+
// have coverage from the 'gcc' case above.
275+
if inLUCIBuild() {
276+
return false
277+
}
269278
return true
270279
default:
271280
return false
272281
}
273282
}
274283

284+
// inLUCIBuild returns true if we're currently executing in a LUCI build.
285+
func inLUCIBuild() bool {
286+
u, err := user.Current()
287+
if err != nil {
288+
return false
289+
}
290+
return testenv.Builder() != "" && u.Username == "swarming"
291+
}
292+
275293
// compilerRequiredTsanVersion reports whether the compiler is the version required by Tsan.
276294
// Only restrictions for ppc64le are known; otherwise return true.
277295
func compilerRequiredTsanVersion(goos, goarch string) bool {

src/cmd/compile/internal/inline/inl.go

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,29 @@ func CanInlineFuncs(funcs []*ir.Func, profile *pgo.Profile) {
141141
PGOInlinePrologue(profile)
142142
}
143143

144-
ir.VisitFuncsBottomUp(funcs, func(list []*ir.Func, recursive bool) {
145-
CanInlineSCC(list, recursive, profile)
146-
})
147-
}
148-
149-
// CanInlineSCC computes the inlinability of functions within an SCC
150-
// (strongly connected component).
151-
//
152-
// CanInlineSCC is designed to be used by ir.VisitFuncsBottomUp
153-
// callbacks.
154-
func CanInlineSCC(funcs []*ir.Func, recursive bool, profile *pgo.Profile) {
155144
if base.Flag.LowerL == 0 {
156145
return
157146
}
158147

159-
numfns := numNonClosures(funcs)
148+
ir.VisitFuncsBottomUp(funcs, func(funcs []*ir.Func, recursive bool) {
149+
numfns := numNonClosures(funcs)
160150

161-
for _, fn := range funcs {
162-
if !recursive || numfns > 1 {
163-
// We allow inlining if there is no
164-
// recursion, or the recursion cycle is
165-
// across more than one function.
166-
CanInline(fn, profile)
167-
} else {
168-
if base.Flag.LowerM > 1 && fn.OClosure == nil {
169-
fmt.Printf("%v: cannot inline %v: recursive\n", ir.Line(fn), fn.Nname)
151+
for _, fn := range funcs {
152+
if !recursive || numfns > 1 {
153+
// We allow inlining if there is no
154+
// recursion, or the recursion cycle is
155+
// across more than one function.
156+
CanInline(fn, profile)
157+
} else {
158+
if base.Flag.LowerM > 1 && fn.OClosure == nil {
159+
fmt.Printf("%v: cannot inline %v: recursive\n", ir.Line(fn), fn.Nname)
160+
}
161+
}
162+
if inlheur.Enabled() {
163+
analyzeFuncProps(fn, profile)
170164
}
171165
}
172-
if inlheur.Enabled() {
173-
analyzeFuncProps(fn, profile)
174-
}
175-
}
166+
})
176167
}
177168

178169
// GarbageCollectUnreferencedHiddenClosures makes a pass over all the

src/cmd/compile/internal/inline/interleaved/interleaved.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,15 @@ func DevirtualizeAndInlinePackage(pkg *ir.Package, profile *pgo.Profile) {
3838
if base.Debug.PGOInline != 0 {
3939
inlProfile = profile
4040
}
41-
if inlProfile != nil {
42-
inline.PGOInlinePrologue(inlProfile)
43-
}
44-
45-
ir.VisitFuncsBottomUp(pkg.Funcs, func(funcs []*ir.Func, recursive bool) {
46-
// We visit functions within an SCC in fairly arbitrary order,
47-
// so by computing inlinability for all functions in the SCC
48-
// before performing any inlining, the results are less
49-
// sensitive to the order within the SCC (see #58905 for an
50-
// example).
5141

52-
// First compute inlinability for all functions in the SCC ...
53-
inline.CanInlineSCC(funcs, recursive, inlProfile)
42+
// First compute inlinability of all functions in the package.
43+
inline.CanInlineFuncs(pkg.Funcs, inlProfile)
5444

55-
// ... then make a second pass to do devirtualization and inlining
56-
// of calls.
57-
for _, fn := range funcs {
58-
DevirtualizeAndInlineFunc(fn, inlProfile)
59-
}
60-
})
45+
// Now we make a second pass to do devirtualization and inlining of
46+
// calls. Order here should not matter.
47+
for _, fn := range pkg.Funcs {
48+
DevirtualizeAndInlineFunc(fn, inlProfile)
49+
}
6150

6251
if base.Flag.LowerL != 0 {
6352
// Perform a garbage collection of hidden closures functions that

src/cmd/compile/internal/noder/reader.go

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,24 @@ func (pr *pkgReader) objInstIdx(info objInfo, dict *readerDict, shaped bool) ir.
663663
}
664664

665665
// objIdx returns the specified object, instantiated with the given
666-
// type arguments, if any. If shaped is true, then the shaped variant
667-
// of the object is returned instead.
666+
// type arguments, if any.
667+
// If shaped is true, then the shaped variant of the object is returned
668+
// instead.
668669
func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Type, shaped bool) ir.Node {
670+
n, err := pr.objIdxMayFail(idx, implicits, explicits, shaped)
671+
if err != nil {
672+
base.Fatalf("%v", err)
673+
}
674+
return n
675+
}
676+
677+
// objIdxMayFail is equivalent to objIdx, but returns an error rather than
678+
// failing the build if this object requires type arguments and the incorrect
679+
// number of type arguments were passed.
680+
//
681+
// Other sources of internal failure (such as duplicate definitions) still fail
682+
// the build.
683+
func (pr *pkgReader) objIdxMayFail(idx pkgbits.Index, implicits, explicits []*types.Type, shaped bool) (ir.Node, error) {
669684
rname := pr.newReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
670685
_, sym := rname.qualifiedIdent()
671686
tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj))
@@ -674,22 +689,25 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
674689
assert(!sym.IsBlank())
675690
switch sym.Pkg {
676691
case types.BuiltinPkg, types.UnsafePkg:
677-
return sym.Def.(ir.Node)
692+
return sym.Def.(ir.Node), nil
678693
}
679694
if pri, ok := objReader[sym]; ok {
680-
return pri.pr.objIdx(pri.idx, nil, explicits, shaped)
695+
return pri.pr.objIdxMayFail(pri.idx, nil, explicits, shaped)
681696
}
682697
if sym.Pkg.Path == "runtime" {
683-
return typecheck.LookupRuntime(sym.Name)
698+
return typecheck.LookupRuntime(sym.Name), nil
684699
}
685700
base.Fatalf("unresolved stub: %v", sym)
686701
}
687702

688-
dict := pr.objDictIdx(sym, idx, implicits, explicits, shaped)
703+
dict, err := pr.objDictIdx(sym, idx, implicits, explicits, shaped)
704+
if err != nil {
705+
return nil, err
706+
}
689707

690708
sym = dict.baseSym
691709
if !sym.IsBlank() && sym.Def != nil {
692-
return sym.Def.(*ir.Name)
710+
return sym.Def.(*ir.Name), nil
693711
}
694712

695713
r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
@@ -725,15 +743,15 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
725743
name := do(ir.OTYPE, false)
726744
setType(name, r.typ())
727745
name.SetAlias(true)
728-
return name
746+
return name, nil
729747

730748
case pkgbits.ObjConst:
731749
name := do(ir.OLITERAL, false)
732750
typ := r.typ()
733751
val := FixValue(typ, r.Value())
734752
setType(name, typ)
735753
setValue(name, val)
736-
return name
754+
return name, nil
737755

738756
case pkgbits.ObjFunc:
739757
if sym.Name == "init" {
@@ -768,7 +786,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
768786
}
769787

770788
rext.funcExt(name, nil)
771-
return name
789+
return name, nil
772790

773791
case pkgbits.ObjType:
774792
name := do(ir.OTYPE, true)
@@ -805,13 +823,13 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
805823
r.needWrapper(typ)
806824
}
807825

808-
return name
826+
return name, nil
809827

810828
case pkgbits.ObjVar:
811829
name := do(ir.ONAME, false)
812830
setType(name, r.typ())
813831
rext.varExt(name)
814-
return name
832+
return name, nil
815833
}
816834
}
817835

@@ -908,7 +926,7 @@ func shapify(targ *types.Type, basic bool) *types.Type {
908926
}
909927

910928
// objDictIdx reads and returns the specified object dictionary.
911-
func (pr *pkgReader) objDictIdx(sym *types.Sym, idx pkgbits.Index, implicits, explicits []*types.Type, shaped bool) *readerDict {
929+
func (pr *pkgReader) objDictIdx(sym *types.Sym, idx pkgbits.Index, implicits, explicits []*types.Type, shaped bool) (*readerDict, error) {
912930
r := pr.newReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1)
913931

914932
dict := readerDict{
@@ -919,7 +937,7 @@ func (pr *pkgReader) objDictIdx(sym *types.Sym, idx pkgbits.Index, implicits, ex
919937
nexplicits := r.Len()
920938

921939
if nimplicits > len(implicits) || nexplicits != len(explicits) {
922-
base.Fatalf("%v has %v+%v params, but instantiated with %v+%v args", sym, nimplicits, nexplicits, len(implicits), len(explicits))
940+
return nil, fmt.Errorf("%v has %v+%v params, but instantiated with %v+%v args", sym, nimplicits, nexplicits, len(implicits), len(explicits))
923941
}
924942

925943
dict.targs = append(implicits[:nimplicits:nimplicits], explicits...)
@@ -984,7 +1002,7 @@ func (pr *pkgReader) objDictIdx(sym *types.Sym, idx pkgbits.Index, implicits, ex
9841002
dict.itabs[i] = itabInfo{typ: r.typInfo(), iface: r.typInfo()}
9851003
}
9861004

987-
return &dict
1005+
return &dict, nil
9881006
}
9891007

9901008
func (r *reader) typeParamNames() {
@@ -2529,7 +2547,10 @@ func (pr *pkgReader) objDictName(idx pkgbits.Index, implicits, explicits []*type
25292547
base.Fatalf("unresolved stub: %v", sym)
25302548
}
25312549

2532-
dict := pr.objDictIdx(sym, idx, implicits, explicits, false)
2550+
dict, err := pr.objDictIdx(sym, idx, implicits, explicits, false)
2551+
if err != nil {
2552+
base.Fatalf("%v", err)
2553+
}
25332554

25342555
return pr.dictNameOf(dict)
25352556
}

src/cmd/compile/internal/noder/unified.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func lookupFunction(pkg *types.Pkg, symName string) (*ir.Func, error) {
8080
return nil, fmt.Errorf("func sym %v missing objReader", sym)
8181
}
8282

83-
name := pri.pr.objIdx(pri.idx, nil, nil, false).(*ir.Name)
83+
node, err := pri.pr.objIdxMayFail(pri.idx, nil, nil, false)
84+
if err != nil {
85+
return nil, fmt.Errorf("func sym %v lookup error: %w", sym, err)
86+
}
87+
name := node.(*ir.Name)
8488
if name.Op() != ir.ONAME || name.Class != ir.PFUNC {
8589
return nil, fmt.Errorf("func sym %v refers to non-function name: %v", sym, name)
8690
}
@@ -105,7 +109,11 @@ func lookupMethod(pkg *types.Pkg, symName string) (*ir.Func, error) {
105109
return nil, fmt.Errorf("type sym %v missing objReader", typ)
106110
}
107111

108-
name := pri.pr.objIdx(pri.idx, nil, nil, false).(*ir.Name)
112+
node, err := pri.pr.objIdxMayFail(pri.idx, nil, nil, false)
113+
if err != nil {
114+
return nil, fmt.Errorf("func sym %v lookup error: %w", typ, err)
115+
}
116+
name := node.(*ir.Name)
109117
if name.Op() != ir.OTYPE {
110118
return nil, fmt.Errorf("type sym %v refers to non-type name: %v", typ, name)
111119
}

src/cmd/compile/internal/pgo/irgraph.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ type NamedCallEdge struct {
108108
CallerName string
109109
CalleeName string
110110
CallSiteOffset int // Line offset from function start line.
111-
CallStartLine int // Start line of the function. Can be 0 which means missing.
112111
}
113112

114113
// NamedEdgeMap contains all unique call edges in the profile and their
@@ -336,20 +335,19 @@ func createNamedEdgeMapFromPreprocess(r io.Reader) (edgeMap NamedEdgeMap, totalW
336335

337336
split := strings.Split(readStr, " ")
338337

339-
if len(split) != 5 {
340-
return NamedEdgeMap{}, 0, fmt.Errorf("preprocessed profile entry got %v want 5 fields", split)
338+
if len(split) != 2 {
339+
return NamedEdgeMap{}, 0, fmt.Errorf("preprocessed profile entry got %v want 2 fields", split)
341340
}
342341

343342
co, _ := strconv.Atoi(split[0])
344-
cs, _ := strconv.Atoi(split[1])
345343

346344
namedEdge := NamedCallEdge{
347345
CallerName: callerName,
348-
CallSiteOffset: co - cs,
346+
CalleeName: calleeName,
347+
CallSiteOffset: co,
349348
}
350349

351-
namedEdge.CalleeName = calleeName
352-
EWeight, _ := strconv.ParseInt(split[4], 10, 64)
350+
EWeight, _ := strconv.ParseInt(split[1], 10, 64)
353351

354352
weight[namedEdge] += EWeight
355353
totalWeight += EWeight

src/cmd/compile/internal/reflectdata/reflect.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,20 +1331,25 @@ func writeITab(lsym *obj.LSym, typ, iface *types.Type, allowNonImplement bool) {
13311331
// _ [4]byte
13321332
// fun [1]uintptr // variable sized. fun[0]==0 means _type does not implement inter.
13331333
// }
1334-
o := objw.SymPtr(lsym, 0, writeType(iface), 0)
1335-
o = objw.SymPtr(lsym, o, writeType(typ), 0)
1336-
o = objw.Uint32(lsym, o, types.TypeHash(typ)) // copy of type hash
1337-
o += 4 // skip unused field
1334+
c := rttype.NewCursor(lsym, 0, rttype.ITab)
1335+
c.Field("Inter").WritePtr(writeType(iface))
1336+
c.Field("Type").WritePtr(writeType(typ))
1337+
c.Field("Hash").WriteUint32(types.TypeHash(typ)) // copy of type hash
1338+
1339+
var delta int64
1340+
c = c.Field("Fun")
13381341
if !completeItab {
13391342
// If typ doesn't implement iface, make method entries be zero.
1340-
o = objw.Uintptr(lsym, o, 0)
1341-
entries = entries[:0]
1342-
}
1343-
for _, fn := range entries {
1344-
o = objw.SymPtrWeak(lsym, o, fn, 0) // method pointer for each method
1343+
c.Elem(0).WriteUintptr(0)
1344+
} else {
1345+
var a rttype.ArrayCursor
1346+
a, delta = c.ModifyArray(len(entries))
1347+
for i, fn := range entries {
1348+
a.Elem(i).WritePtrWeak(fn) // method pointer for each method
1349+
}
13451350
}
13461351
// Nothing writes static itabs, so they are read only.
1347-
objw.Global(lsym, int32(o), int16(obj.DUPOK|obj.RODATA))
1352+
objw.Global(lsym, int32(rttype.ITab.Size()+delta), int16(obj.DUPOK|obj.RODATA))
13481353
lsym.Set(obj.AttrContentAddressable, true)
13491354
}
13501355

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
278278
p.To.Type = obj.TYPE_REG
279279
p.To.Reg = rd
280280
case ssa.OpRISCV64ADD, ssa.OpRISCV64SUB, ssa.OpRISCV64SUBW, ssa.OpRISCV64XOR, ssa.OpRISCV64OR, ssa.OpRISCV64AND,
281-
ssa.OpRISCV64SLL, ssa.OpRISCV64SRA, ssa.OpRISCV64SRAW, ssa.OpRISCV64SRL, ssa.OpRISCV64SRLW,
281+
ssa.OpRISCV64SLL, ssa.OpRISCV64SLLW, ssa.OpRISCV64SRA, ssa.OpRISCV64SRAW, ssa.OpRISCV64SRL, ssa.OpRISCV64SRLW,
282282
ssa.OpRISCV64SLT, ssa.OpRISCV64SLTU, ssa.OpRISCV64MUL, ssa.OpRISCV64MULW, ssa.OpRISCV64MULH,
283283
ssa.OpRISCV64MULHU, ssa.OpRISCV64DIV, ssa.OpRISCV64DIVU, ssa.OpRISCV64DIVW,
284284
ssa.OpRISCV64DIVUW, ssa.OpRISCV64REM, ssa.OpRISCV64REMU, ssa.OpRISCV64REMW,
@@ -422,8 +422,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
422422
p.To.Type = obj.TYPE_REG
423423
p.To.Reg = v.Reg()
424424
case ssa.OpRISCV64ADDI, ssa.OpRISCV64ADDIW, ssa.OpRISCV64XORI, ssa.OpRISCV64ORI, ssa.OpRISCV64ANDI,
425-
ssa.OpRISCV64SLLI, ssa.OpRISCV64SRAI, ssa.OpRISCV64SRAIW, ssa.OpRISCV64SRLI, ssa.OpRISCV64SRLIW, ssa.OpRISCV64SLTI,
426-
ssa.OpRISCV64SLTIU:
425+
ssa.OpRISCV64SLLI, ssa.OpRISCV64SLLIW, ssa.OpRISCV64SRAI, ssa.OpRISCV64SRAIW,
426+
ssa.OpRISCV64SRLI, ssa.OpRISCV64SRLIW, ssa.OpRISCV64SLTI, ssa.OpRISCV64SLTIU:
427427
p := s.Prog(v.Op.Asm())
428428
p.From.Type = obj.TYPE_CONST
429429
p.From.Offset = v.AuxInt

0 commit comments

Comments
 (0)