Skip to content

Commit fd6b85b

Browse files
committed
[release-branch.go1.17] Merge remote-tracking branch 'origin/release-branch.go1.17' into tailscale.go1.17
Change-Id: I1742b29d3333e75df54db9c92d89bde0c4730a9b
2 parents c7700ca + cd6e0d7 commit fd6b85b

File tree

31 files changed

+670
-666
lines changed

31 files changed

+670
-666
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
go1.17.6
1+
go1.17.7

misc/cgo/testplugin/plugin_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,31 @@ func TestIssue44956(t *testing.T) {
293293
goCmd(t, "build", "-o", "issue44956.exe", "./issue44956/main.go")
294294
run(t, "./issue44956.exe")
295295
}
296+
297+
func TestForkExec(t *testing.T) {
298+
// Issue 38824: importing the plugin package causes it hang in forkExec on darwin.
299+
300+
t.Parallel()
301+
goCmd(t, "build", "-o", "forkexec.exe", "./forkexec/main.go")
302+
303+
var cmd *exec.Cmd
304+
done := make(chan int, 1)
305+
306+
go func() {
307+
for i := 0; i < 100; i++ {
308+
cmd = exec.Command("./forkexec.exe", "1")
309+
err := cmd.Run()
310+
if err != nil {
311+
t.Errorf("running command failed: %v", err)
312+
break
313+
}
314+
}
315+
done <- 1
316+
}()
317+
select {
318+
case <-done:
319+
case <-time.After(5 * time.Minute):
320+
cmd.Process.Kill()
321+
t.Fatalf("subprocess hang")
322+
}
323+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2021 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 main
6+
7+
import (
8+
"os"
9+
"os/exec"
10+
_ "plugin"
11+
"sync"
12+
)
13+
14+
func main() {
15+
if os.Args[1] != "1" {
16+
return
17+
}
18+
19+
var wg sync.WaitGroup
20+
for i := 0; i < 8; i++ {
21+
wg.Add(1)
22+
go func() {
23+
defer wg.Done()
24+
// does not matter what we exec, just exec itself
25+
cmd := exec.Command("./forkexec.exe", "0")
26+
cmd.Run()
27+
}()
28+
}
29+
wg.Wait()
30+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
320320
for a.Op == ssa.OpCopy || a.Op == ssa.OpMIPS64MOVVreg {
321321
a = a.Args[0]
322322
}
323-
if a.Op == ssa.OpLoadReg {
323+
if a.Op == ssa.OpLoadReg && mips.REG_R0 <= a.Reg() && a.Reg() <= mips.REG_R31 {
324+
// LoadReg from a narrower type does an extension, except loading
325+
// to a floating point register. So only eliminate the extension
326+
// if it is loaded to an integer register.
324327
t := a.Type
325328
switch {
326329
case v.Op == ssa.OpMIPS64MOVBreg && t.Size() == 1 && t.IsSigned(),

src/cmd/compile/internal/ssa/gen/ARM.rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,8 @@
12681268
(SRLconst (SLLconst x [c]) [d]) && buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFXU [(d-c)|(32-d)<<8] x)
12691269

12701270
// comparison simplification
1271-
((LT|LE|EQ|NE|GE|GT) (CMP x (RSBconst [0] y))) => ((LT|LE|EQ|NE|GE|GT) (CMN x y)) // sense of carry bit not preserved
1272-
((LT|LE|EQ|NE|GE|GT) (CMN x (RSBconst [0] y))) => ((LT|LE|EQ|NE|GE|GT) (CMP x y)) // sense of carry bit not preserved
1271+
((EQ|NE) (CMP x (RSBconst [0] y))) => ((EQ|NE) (CMN x y)) // sense of carry bit not preserved; see also #50854
1272+
((EQ|NE) (CMN x (RSBconst [0] y))) => ((EQ|NE) (CMP x y)) // sense of carry bit not preserved; see also #50864
12731273
(EQ (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 => (EQ (CMP x y) yes no)
12741274
(EQ (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 => (EQ (CMP a (MUL <x.Type> x y)) yes no)
12751275
(EQ (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 => (EQ (CMPconst [c] x) yes no)

src/cmd/compile/internal/ssa/gen/ARM64.rules

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,13 @@
645645
(GT (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GTnoov (CMNW x y) yes no)
646646
(GE (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GEnoov (CMNW x y) yes no)
647647

648+
// CMP(x,-y) -> CMN(x,y) is only valid for unordered comparison, if y can be -1<<63
648649
(EQ (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (EQ (CMN x y) yes no)
649650
(NE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (NE (CMN x y) yes no)
650-
(LT (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (LT (CMN x y) yes no)
651-
(LE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (LE (CMN x y) yes no)
652-
(GT (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (GT (CMN x y) yes no)
653-
(GE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (GE (CMN x y) yes no)
654651

652+
// CMPW(x,-y) -> CMNW(x,y) is only valid for unordered comparison, if y can be -1<<31
655653
(EQ (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (EQ (CMNW x y) yes no)
656654
(NE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (NE (CMNW x y) yes no)
657-
(LT (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (LT (CMNW x y) yes no)
658-
(LE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (LE (CMNW x y) yes no)
659-
(GT (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (GT (CMNW x y) yes no)
660-
(GE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (GE (CMNW x y) yes no)
661655

662656
(EQ (CMPconst [0] x) yes no) => (Z x yes no)
663657
(NE (CMPconst [0] x) yes no) => (NZ x yes no)

src/cmd/compile/internal/ssa/gen/ARM64Ops.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ func init() {
284284
{name: "CMPconst", argLength: 1, reg: gp1flags, asm: "CMP", aux: "Int64", typ: "Flags"}, // arg0 compare to auxInt
285285
{name: "CMPW", argLength: 2, reg: gp2flags, asm: "CMPW", typ: "Flags"}, // arg0 compare to arg1, 32 bit
286286
{name: "CMPWconst", argLength: 1, reg: gp1flags, asm: "CMPW", aux: "Int32", typ: "Flags"}, // arg0 compare to auxInt, 32 bit
287-
{name: "CMN", argLength: 2, reg: gp2flags, asm: "CMN", typ: "Flags", commutative: true}, // arg0 compare to -arg1
287+
{name: "CMN", argLength: 2, reg: gp2flags, asm: "CMN", typ: "Flags", commutative: true}, // arg0 compare to -arg1, provided arg1 is not 1<<63
288288
{name: "CMNconst", argLength: 1, reg: gp1flags, asm: "CMN", aux: "Int64", typ: "Flags"}, // arg0 compare to -auxInt
289-
{name: "CMNW", argLength: 2, reg: gp2flags, asm: "CMNW", typ: "Flags", commutative: true}, // arg0 compare to -arg1, 32 bit
289+
{name: "CMNW", argLength: 2, reg: gp2flags, asm: "CMNW", typ: "Flags", commutative: true}, // arg0 compare to -arg1, 32 bit, provided arg1 is not 1<<31
290290
{name: "CMNWconst", argLength: 1, reg: gp1flags, asm: "CMNW", aux: "Int32", typ: "Flags"}, // arg0 compare to -auxInt, 32 bit
291291
{name: "TST", argLength: 2, reg: gp2flags, asm: "TST", typ: "Flags", commutative: true}, // arg0 & arg1 compare to 0
292292
{name: "TSTconst", argLength: 1, reg: gp1flags, asm: "TST", aux: "Int64", typ: "Flags"}, // arg0 & auxInt compare to 0

src/cmd/compile/internal/ssa/gen/ARMOps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func init() {
331331
// comparisons
332332
{name: "CMP", argLength: 2, reg: gp2flags, asm: "CMP", typ: "Flags"}, // arg0 compare to arg1
333333
{name: "CMPconst", argLength: 1, reg: gp1flags, asm: "CMP", aux: "Int32", typ: "Flags"}, // arg0 compare to auxInt
334-
{name: "CMN", argLength: 2, reg: gp2flags, asm: "CMN", typ: "Flags", commutative: true}, // arg0 compare to -arg1
334+
{name: "CMN", argLength: 2, reg: gp2flags, asm: "CMN", typ: "Flags", commutative: true}, // arg0 compare to -arg1, provided arg1 is not 1<<63
335335
{name: "CMNconst", argLength: 1, reg: gp1flags, asm: "CMN", aux: "Int32", typ: "Flags"}, // arg0 compare to -auxInt
336336
{name: "TST", argLength: 2, reg: gp2flags, asm: "TST", typ: "Flags", commutative: true}, // arg0 & arg1 compare to 0
337337
{name: "TSTconst", argLength: 1, reg: gp1flags, asm: "TST", aux: "Int32", typ: "Flags"}, // arg0 & auxInt compare to 0

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

Lines changed: 0 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)