aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-16 10:22:34 -0400
committerCherry Mui <cherryyz@google.com>2025-09-16 10:22:34 -0400
commitbdd30e25caa0b69e335ba1f1f48566924850fa4b (patch)
tree3f7dba7bae3eaf8de272679aa7a00bf85585cd16 /src/cmd/compile/internal
parent0e590a505d7f1050ac60df4b52c414cfc618239d (diff)
parentca0e03560df7279bc307da08db7237beb32b0d99 (diff)
downloadgo-bdd30e25caa0b69e335ba1f1f48566924850fa4b.tar.xz
[dev.simd] all: merge master (ca0e035) into dev.simd
Conflicts: - src/internal/goexperiment/flags.go Merge List: + 2025-09-15 ca0e03560d cmd/link: remove support for windows/arm relocations + 2025-09-15 17a0fabc43 cmd/link: remove support for darwin/386 relocations + 2025-09-15 eb7c67fdc9 cmd/internal/obj/loong64: use the MOVVP instruction to optimize prologue + 2025-09-15 6b8d507508 cmd/internal/obj/riscv: implement vector segment load/store instructions + 2025-09-15 7ddbf4d820 cmd/asm: add double precision comparision testcases for riscv64 + 2025-09-15 c39abe0658 runtime: fix TestSehUnwind + 2025-09-15 e3ed0fbe6a all: replace strings.Split with strings.SplitSeq + 2025-09-15 10bfddc91d all: remove redundant words in comment + 2025-09-15 2469e92d8c cmd/compile: combine doubling with shift on riscv64 + 2025-09-15 aa83aee7de net/http: clarify panic conditions in Handle, HandleFunc, AddInsecureBypassPattern + 2025-09-15 b9e2977f1d crypto/internal/cryptotest: use linux-amd64_avx512 builder for SHA-NI + 2025-09-15 8105d0ccc2 cmd/go,crypto/internal/fips140: prevent using FIPS 140-3 mode with purego tag + 2025-09-15 7f70ca8726 crypto/internal/cryptotest: add MustSupportFIPS140 + 2025-09-15 9e71d8a9f7 cmd/internal/testdir: re-enable default all codegen flag on linux-amd64 + 2025-09-15 004858ccdd all: replace os.Getenv("GO_BUILDER_NAME") with testenv.Builder in tests + 2025-09-15 dbde15800c cmd: vendor x/tools@9fccddc + 2025-09-15 8ace10dad2 os: add (*Process).WithHandle + 2025-09-15 3573227fe3 os: add and use errProcessReleased + 2025-09-15 68c6a73380 internal/syscall/unix: add KernelVersionGE + 2025-09-15 e603e9834e cmd/link: support race mode with MSVC clang + 2025-09-15 e5ee1f2600 test/codegen: check zerobase for newobject on 0-sized types + 2025-09-15 77b93d41d5 net/http: add comments for transport gzip reader + 2025-09-15 30d510ca2d cmd/compile,cmd/gofmt: use reflect.TypeFor + 2025-09-15 8320fe8f0e runtime: deduplicate syscall assembly for darwin + 2025-09-14 080882a928 net: use context.AfterFunc in connect + 2025-09-12 ac803b5949 cmd/go/internal/work: copy vet tool's stdout to our stdout + 2025-09-12 889e71c2ac runtime: move Windows types and consts to internal/runtime/syscall/windows + 2025-09-12 cc8a6780ac vendor: update x/tools to 3adf0e9, and other repos + 2025-09-12 911455fe18 cmd/link: don't count tbss section in TestFlagD + 2025-09-12 f1fd13016a cmd/compile: optimize abi.Type.GCData loads + 2025-09-12 dc960d0bfe cmd/compile, reflect: further allow inlining of TypeFor + 2025-09-12 7acb0d0446 runtime: fix syscall9 on darwin/arm64 + 2025-09-12 60c1ee9183 internal/goexperiment: add a sizespecializedmalloc goexperiment setting + 2025-09-12 c70713da82 cmd/link: support MSVC clang + 2025-09-12 9271bbbb80 internal/testenv: update Builder docs with LUCI builder names + 2025-09-12 a4e25c3d65 net,internal/poll: skip TestAllocs when race is enabled on Windows + 2025-09-12 dd8276657f cmd/asm, cmd/internal/obj: add riscv64 generic CSR ops + 2025-09-11 f37d75472d runtime: move mksizeclasses.go to runtime/_mkmalloc + 2025-09-11 73676e3223 cmd/go: run cgo and cgo compiles in their own actions + 2025-09-11 0e1b98993e testing: exit B.Loop early upon saturation + 2025-09-11 84e9ab3984 cmd/go/internal/work: remove deps[1]="fmt" vet hack Change-Id: I1424228bcd9291c9ff29f6ae843d5b90652f237e
Diffstat (limited to 'src/cmd/compile/internal')
-rw-r--r--src/cmd/compile/internal/base/flag.go18
-rw-r--r--src/cmd/compile/internal/ir/fmt.go2
-rw-r--r--src/cmd/compile/internal/liveness/plive.go2
-rw-r--r--src/cmd/compile/internal/reflectdata/reflect.go8
-rw-r--r--src/cmd/compile/internal/rttype/rttype.go32
-rw-r--r--src/cmd/compile/internal/ssa/_gen/RISCV64.rules4
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go8
-rw-r--r--src/cmd/compile/internal/ssa/rewriteRISCV64.go36
8 files changed, 80 insertions, 30 deletions
diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go
index e87f57cdaa..a0ed876cfc 100644
--- a/src/cmd/compile/internal/base/flag.go
+++ b/src/cmd/compile/internal/base/flag.go
@@ -383,14 +383,14 @@ func ParseFlags() {
// See the comment on type CmdFlags for the rules.
func registerFlags() {
var (
- boolType = reflect.TypeOf(bool(false))
- intType = reflect.TypeOf(int(0))
- stringType = reflect.TypeOf(string(""))
- ptrBoolType = reflect.TypeOf(new(bool))
- ptrIntType = reflect.TypeOf(new(int))
- ptrStringType = reflect.TypeOf(new(string))
- countType = reflect.TypeOf(CountFlag(0))
- funcType = reflect.TypeOf((func(string))(nil))
+ boolType = reflect.TypeFor[bool]()
+ intType = reflect.TypeFor[int]()
+ stringType = reflect.TypeFor[string]()
+ ptrBoolType = reflect.TypeFor[*bool]()
+ ptrIntType = reflect.TypeFor[*int]()
+ ptrStringType = reflect.TypeFor[*string]()
+ countType = reflect.TypeFor[CountFlag]()
+ funcType = reflect.TypeFor[func(string)]()
)
v := reflect.ValueOf(&Flag).Elem()
@@ -570,7 +570,7 @@ func readEmbedCfg(file string) {
// parseSpectre parses the spectre configuration from the string s.
func parseSpectre(s string) {
- for _, f := range strings.Split(s, ",") {
+ for f := range strings.SplitSeq(s, ",") {
f = strings.TrimSpace(f)
switch f {
default:
diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go
index 31c610348b..ae4ff62652 100644
--- a/src/cmd/compile/internal/ir/fmt.go
+++ b/src/cmd/compile/internal/ir/fmt.go
@@ -1194,7 +1194,7 @@ func dumpNode(w io.Writer, n Node, depth int) {
}
}
-var nodeType = reflect.TypeOf((*Node)(nil)).Elem()
+var nodeType = reflect.TypeFor[Node]()
func dumpNodes(w io.Writer, list Nodes, depth int) {
if len(list) == 0 {
diff --git a/src/cmd/compile/internal/liveness/plive.go b/src/cmd/compile/internal/liveness/plive.go
index 6c1435c724..63c85ea26d 100644
--- a/src/cmd/compile/internal/liveness/plive.go
+++ b/src/cmd/compile/internal/liveness/plive.go
@@ -1493,7 +1493,7 @@ func (lv *Liveness) emitStackObjects() *obj.LSym {
if sz != int64(int32(sz)) {
base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz)
}
- lsym, ptrBytes := reflectdata.GCSym(t)
+ lsym, ptrBytes := reflectdata.GCSym(t, false)
off = objw.Uint32(x, off, uint32(sz))
off = objw.Uint32(x, off, uint32(ptrBytes))
off = objw.SymPtrOff(x, off, lsym)
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go
index 2849d4ee40..38b9391c5f 100644
--- a/src/cmd/compile/internal/reflectdata/reflect.go
+++ b/src/cmd/compile/internal/reflectdata/reflect.go
@@ -717,6 +717,10 @@ func writeType(t *types.Type) *obj.LSym {
}
s.SetSiggen(true)
+ if !tbase.HasShape() {
+ TypeLinksym(t) // ensure lsym.Extra is set
+ }
+
if !NeedEmit(tbase) {
if i := typecheck.BaseTypeIndex(t); i >= 0 {
lsym.Pkg = tbase.Sym().Pkg.Prefix
@@ -1225,7 +1229,7 @@ func typesStrCmp(a, b typeAndStr) int {
// GC information is always a bitmask, never a gc program.
// GCSym may be called in concurrent backend, so it does not emit the symbol
// content.
-func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
+func GCSym(t *types.Type, onDemandAllowed bool) (lsym *obj.LSym, ptrdata int64) {
// Record that we need to emit the GC symbol.
gcsymmu.Lock()
if _, ok := gcsymset[t]; !ok {
@@ -1233,7 +1237,7 @@ func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
}
gcsymmu.Unlock()
- lsym, _, ptrdata = dgcsym(t, false, false)
+ lsym, _, ptrdata = dgcsym(t, false, onDemandAllowed)
return
}
diff --git a/src/cmd/compile/internal/rttype/rttype.go b/src/cmd/compile/internal/rttype/rttype.go
index 925d3901d4..b8c9533991 100644
--- a/src/cmd/compile/internal/rttype/rttype.go
+++ b/src/cmd/compile/internal/rttype/rttype.go
@@ -49,25 +49,25 @@ func Init() {
// Note: this has to be called explicitly instead of being
// an init function so it runs after the types package has
// been properly initialized.
- Type = FromReflect(reflect.TypeOf(abi.Type{}))
- ArrayType = FromReflect(reflect.TypeOf(abi.ArrayType{}))
- ChanType = FromReflect(reflect.TypeOf(abi.ChanType{}))
- FuncType = FromReflect(reflect.TypeOf(abi.FuncType{}))
- InterfaceType = FromReflect(reflect.TypeOf(abi.InterfaceType{}))
- MapType = FromReflect(reflect.TypeOf(abi.MapType{}))
- PtrType = FromReflect(reflect.TypeOf(abi.PtrType{}))
- SliceType = FromReflect(reflect.TypeOf(abi.SliceType{}))
- StructType = FromReflect(reflect.TypeOf(abi.StructType{}))
+ Type = FromReflect(reflect.TypeFor[abi.Type]())
+ ArrayType = FromReflect(reflect.TypeFor[abi.ArrayType]())
+ ChanType = FromReflect(reflect.TypeFor[abi.ChanType]())
+ FuncType = FromReflect(reflect.TypeFor[abi.FuncType]())
+ InterfaceType = FromReflect(reflect.TypeFor[abi.InterfaceType]())
+ MapType = FromReflect(reflect.TypeFor[abi.MapType]())
+ PtrType = FromReflect(reflect.TypeFor[abi.PtrType]())
+ SliceType = FromReflect(reflect.TypeFor[abi.SliceType]())
+ StructType = FromReflect(reflect.TypeFor[abi.StructType]())
- IMethod = FromReflect(reflect.TypeOf(abi.Imethod{}))
- Method = FromReflect(reflect.TypeOf(abi.Method{}))
- StructField = FromReflect(reflect.TypeOf(abi.StructField{}))
- UncommonType = FromReflect(reflect.TypeOf(abi.UncommonType{}))
+ IMethod = FromReflect(reflect.TypeFor[abi.Imethod]())
+ Method = FromReflect(reflect.TypeFor[abi.Method]())
+ StructField = FromReflect(reflect.TypeFor[abi.StructField]())
+ UncommonType = FromReflect(reflect.TypeFor[abi.UncommonType]())
- InterfaceSwitch = FromReflect(reflect.TypeOf(abi.InterfaceSwitch{}))
- TypeAssert = FromReflect(reflect.TypeOf(abi.TypeAssert{}))
+ InterfaceSwitch = FromReflect(reflect.TypeFor[abi.InterfaceSwitch]())
+ TypeAssert = FromReflect(reflect.TypeFor[abi.TypeAssert]())
- ITab = FromReflect(reflect.TypeOf(abi.ITab{}))
+ ITab = FromReflect(reflect.TypeFor[abi.ITab]())
// Make sure abi functions are correct. These functions are used
// by the linker which doesn't have the ability to do type layout,
diff --git a/src/cmd/compile/internal/ssa/_gen/RISCV64.rules b/src/cmd/compile/internal/ssa/_gen/RISCV64.rules
index e14de328ea..7059273eb2 100644
--- a/src/cmd/compile/internal/ssa/_gen/RISCV64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/RISCV64.rules
@@ -782,6 +782,10 @@
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> uint32(x))])
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> uint32(x)])
+// Combine doubling via addition with shift.
+(SLLI <t> [c] (ADD x x)) && c < t.Size() * 8 - 1 => (SLLI <t> [c+1] x)
+(SLLI <t> [c] (ADD x x)) && c >= t.Size() * 8 - 1 => (MOVDconst [0])
+
// SLTI/SLTIU with constants.
(SLTI [x] (MOVDconst [y])) => (MOVDconst [b2i(int64(y) < int64(x))])
(SLTIU [x] (MOVDconst [y])) => (MOVDconst [b2i(uint64(y) < uint64(x))])
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 6fb2689d18..6d83ba5653 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -2067,7 +2067,7 @@ func isFixedLoad(v *Value, sym Sym, off int64) bool {
for _, f := range rttype.Type.Fields() {
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
switch f.Sym.Name {
- case "Size_", "PtrBytes", "Hash", "Kind_":
+ case "Size_", "PtrBytes", "Hash", "Kind_", "GCData":
return true
default:
// fmt.Println("unknown field", f.Sym.Name)
@@ -2147,6 +2147,12 @@ func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value {
v.reset(OpConst8)
v.AuxInt = int64(reflectdata.ABIKindOfType(t))
return v
+ case "GCData":
+ gcdata, _ := reflectdata.GCSym(t, true)
+ v.reset(OpAddr)
+ v.Aux = symToAux(gcdata)
+ v.AddArg(sb)
+ return v
default:
base.Fatalf("unknown field %s for fixedLoad of %s at offset %d", f.Sym.Name, lsym.Name, off)
}
diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
index 5723327bc9..a7b4cf1bc4 100644
--- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go
+++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
@@ -7185,6 +7185,42 @@ func rewriteValueRISCV64_OpRISCV64SLLI(v *Value) bool {
v.AuxInt = int64ToAuxInt(y << uint32(x))
return true
}
+ // match: (SLLI <t> [c] (ADD x x))
+ // cond: c < t.Size() * 8 - 1
+ // result: (SLLI <t> [c+1] x)
+ for {
+ t := v.Type
+ c := auxIntToInt64(v.AuxInt)
+ if v_0.Op != OpRISCV64ADD {
+ break
+ }
+ x := v_0.Args[1]
+ if x != v_0.Args[0] || !(c < t.Size()*8-1) {
+ break
+ }
+ v.reset(OpRISCV64SLLI)
+ v.Type = t
+ v.AuxInt = int64ToAuxInt(c + 1)
+ v.AddArg(x)
+ return true
+ }
+ // match: (SLLI <t> [c] (ADD x x))
+ // cond: c >= t.Size() * 8 - 1
+ // result: (MOVDconst [0])
+ for {
+ t := v.Type
+ c := auxIntToInt64(v.AuxInt)
+ if v_0.Op != OpRISCV64ADD {
+ break
+ }
+ x := v_0.Args[1]
+ if x != v_0.Args[0] || !(c >= t.Size()*8-1) {
+ break
+ }
+ v.reset(OpRISCV64MOVDconst)
+ v.AuxInt = int64ToAuxInt(0)
+ return true
+ }
return false
}
func rewriteValueRISCV64_OpRISCV64SLLW(v *Value) bool {