]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.unified] all: merge master (462b78f) into dev.unified
authorMatthew Dempsky <mdempsky@google.com>
Thu, 28 Jul 2022 07:32:28 +0000 (00:32 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 28 Jul 2022 07:32:28 +0000 (00:32 -0700)
Merge List:

+ 2022-07-27 462b78fe70 misc/cgo/test: use fewer threads in TestSetgidStress in long mode
+ 2022-07-27 055113ef36 math/big: check buffer lengths in GobDecode
+ 2022-07-27 4248146154 net: document UDPConn.ReadFromUDPAddrPort's AddrPort result more
+ 2022-07-26 faf4e97200 net: fix WriteMsgUDPAddrPort addr handling
+ 2022-07-26 caa225dd29 doc/go1.19: note that updated race syso files require GNU ld 2.26
+ 2022-07-26 ceefd3a37b bytes: document that Reader.Reset affects the result of Size
+ 2022-07-26 3e97294663 runtime/cgo: use frame address to set g0 stack bound
+ 2022-07-25 24dc27a3c0 cmd/compile: fix blank label code
+ 2022-07-25 9fcc8b2c1e runtime: fix runtime.Breakpoint() on windows/arm64
+ 2022-07-25 795a88d0c3 cmd/go: add space after comma in 'go help test'
+ 2022-07-25 9eb3992ddd doc/go1.19: minor fixes
+ 2022-07-25 dcea1ee6e3 time: clarify documentation for allowed formats and add tests to prove them
+ 2022-07-25 37c8112b82 internal/fuzz: fix typo in function comments
+ 2022-07-25 850d547d2d doc/go1.19: expand crypto release notes
+ 2022-07-24 64f2829c9c runtime: fix typo in function comments
+ 2022-07-24 2ff563a00e cmd/compile/internal/noder: correct spelling errors for instantiation
+ 2022-07-22 c5da4fb7ac cmd/compile: make jump table symbol local
+ 2022-07-22 774fa58d1d A+C: delete AUTHORS and CONTRIBUTORS
+ 2022-07-21 2d655fb15a unsafe: document when Sizeof/Offsetof/Alignof are not constant
+ 2022-07-21 076c3d7f07 net/http: remove accidental heading in Head documentation
+ 2022-07-21 c4a6d3048b cmd/dist: enable race detector test on S390X
+ 2022-07-20 244c8b0500 cmd/cgo: allow cgo to pass strings or []bytes bigger than 1<<30
+ 2022-07-20 df38614bd7 test: use go tool from tree, not path
+ 2022-07-20 bb1749ba3b cmd/compile: improve GOAMD64=v1 violation test
+ 2022-07-19 176b63e711 crypto/internal/nistec,debug/gosym: fix typos

Change-Id: I96e5d60039381691dffd841e58927f0afff8c544

1  2 
src/cmd/compile/internal/ssagen/ssa.go
test/run.go

index 64a30d427fb0d54b800b00b35a57fbc28bc1964c,2ee027092e9369ddc87342377379a011f49126a6..1e5313f95e99048f8f006530271ff609827285d9
@@@ -664,7 -664,7 +664,7 @@@ func (s *state) paramsToHeap() 
  
  // newHeapaddr allocates heap memory for n and sets its heap address.
  func (s *state) newHeapaddr(n *ir.Name) {
 -      s.setHeapaddr(n.Pos(), n, s.newObject(n.Type()))
 +      s.setHeapaddr(n.Pos(), n, s.newObject(n.Type(), nil))
  }
  
  // setHeapaddr allocates a new PAUTO variable to store ptr (which must be non-nil)
@@@ -692,26 -692,23 +692,26 @@@ func (s *state) setHeapaddr(pos src.XPo
  }
  
  // newObject returns an SSA value denoting new(typ).
 -func (s *state) newObject(typ *types.Type) *ssa.Value {
 +func (s *state) newObject(typ *types.Type, rtype *ssa.Value) *ssa.Value {
        if typ.Size() == 0 {
                return s.newValue1A(ssa.OpAddr, types.NewPtr(typ), ir.Syms.Zerobase, s.sb)
        }
 -      return s.rtcall(ir.Syms.Newobject, true, []*types.Type{types.NewPtr(typ)}, s.reflectType(typ))[0]
 +      if rtype == nil {
 +              rtype = s.reflectType(typ)
 +      }
 +      return s.rtcall(ir.Syms.Newobject, true, []*types.Type{types.NewPtr(typ)}, rtype)[0]
  }
  
  func (s *state) checkPtrAlignment(n *ir.ConvExpr, v *ssa.Value, count *ssa.Value) {
        if !n.Type().IsPtr() {
                s.Fatalf("expected pointer type: %v", n.Type())
        }
 -      elem := n.Type().Elem()
 +      elem, rtypeExpr := n.Type().Elem(), n.ElemRType
        if count != nil {
                if !elem.IsArray() {
                        s.Fatalf("expected array type: %v", elem)
                }
 -              elem = elem.Elem()
 +              elem, rtypeExpr = elem.Elem(), n.ElemElemRType
        }
        size := elem.Size()
        // Casting from larger type to smaller one is ok, so for smallest type, do nothing.
        if count.Type.Size() != s.config.PtrSize {
                s.Fatalf("expected count fit to an uintptr size, have: %d, want: %d", count.Type.Size(), s.config.PtrSize)
        }
 -      s.rtcall(ir.Syms.CheckPtrAlignment, true, nil, v, s.reflectType(elem), count)
 +      var rtype *ssa.Value
 +      if rtypeExpr != nil {
 +              rtype = s.expr(rtypeExpr)
 +      } else {
 +              rtype = s.reflectType(elem)
 +      }
 +      s.rtcall(ir.Syms.CheckPtrAlignment, true, nil, v, rtype, count)
  }
  
  // reflectType returns an SSA value representing a pointer to typ's
  // reflection type descriptor.
  func (s *state) reflectType(typ *types.Type) *ssa.Value {
 +      // TODO(mdempsky): Make this Fatalf under Unified IR; frontend needs
 +      // to supply RType expressions.
        lsym := reflectdata.TypeLinksym(typ)
        return s.entryNewValue1A(ssa.OpAddr, types.NewPtr(types.Types[types.TUINT8]), lsym, s.sb)
  }
@@@ -1507,6 -1496,10 +1507,10 @@@ func (s *state) stmt(n ir.Node) 
        case ir.OLABEL:
                n := n.(*ir.LabelStmt)
                sym := n.Label
+               if sym.IsBlank() {
+                       // Nothing to do because the label isn't targetable. See issue 52278.
+                       break
+               }
                lab := s.label(sym)
  
                // The label might already have a target block via a goto.
@@@ -3301,11 -3294,7 +3305,11 @@@ func (s *state) exprCheckPtr(n ir.Node
  
        case ir.ONEW:
                n := n.(*ir.UnaryExpr)
 -              return s.newObject(n.Type().Elem())
 +              var rtype *ssa.Value
 +              if x, ok := n.X.(*ir.DynamicType); ok && x.Op() == ir.ODYNAMICTYPE {
 +                      rtype = s.expr(x.RType)
 +              }
 +              return s.newObject(n.Type().Elem(), rtype)
  
        case ir.OUNSAFEADD:
                n := n.(*ir.BinaryExpr)
@@@ -6237,15 -6226,12 +6241,15 @@@ func (s *state) dottype(n *ir.TypeAsser
        if n.ITab != nil {
                targetItab = s.expr(n.ITab)
        }
 -      return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, target, targetItab, commaok)
 +      return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, nil, target, targetItab, commaok)
  }
  
  func (s *state) dynamicDottype(n *ir.DynamicTypeAssertExpr, commaok bool) (res, resok *ssa.Value) {
        iface := s.expr(n.X)
 -      var target, targetItab *ssa.Value
 +      var source, target, targetItab *ssa.Value
 +      if n.SrcRType != nil {
 +              source = s.expr(n.SrcRType)
 +      }
        if !n.X.Type().IsEmptyInterface() && !n.Type().IsInterface() {
                byteptr := s.f.Config.Types.BytePtr
                targetItab = s.expr(n.ITab)
        } else {
                target = s.expr(n.RType)
        }
 -      return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, target, targetItab, commaok)
 +      return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, source, target, targetItab, commaok)
  }
  
  // dottype1 implements a x.(T) operation. iface is the argument (x), dst is the type we're asserting to (T)
  // and src is the type we're asserting from.
 +// source is the *runtime._type of src
  // target is the *runtime._type of dst.
  // If src is a nonempty interface and dst is not an interface, targetItab is an itab representing (dst, src). Otherwise it is nil.
  // commaok is true if the caller wants a boolean success value. Otherwise, the generated code panics if the conversion fails.
 -func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, target, targetItab *ssa.Value, commaok bool) (res, resok *ssa.Value) {
 +func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, target, targetItab *ssa.Value, commaok bool) (res, resok *ssa.Value) {
        byteptr := s.f.Config.Types.BytePtr
        if dst.IsInterface() {
                if dst.IsEmptyInterface() {
        if !commaok {
                // on failure, panic by calling panicdottype
                s.startBlock(bFail)
 -              taddr := s.reflectType(src)
 +              taddr := source
 +              if taddr == nil {
 +                      taddr = s.reflectType(src)
 +              }
                if src.IsEmptyInterface() {
                        s.rtcall(ir.Syms.PanicdottypeE, false, nil, itab, target, taddr)
                } else {
diff --combined test/run.go
index fc03e1796be12af4fdb79ba761c91a3f744ae1c5,b2902f190c357e1158bf3fa8083472db5f39617e..4a992037615e43ca074adfec8a40f2bf8de59826
@@@ -58,7 -58,7 +58,7 @@@ type envVars struct 
  }
  
  var env = func() (res envVars) {
-       cmd := exec.Command("go", "env", "-json")
+       cmd := exec.Command(goTool(), "env", "-json")
        stdout, err := cmd.StdoutPipe()
        if err != nil {
                log.Fatal("StdoutPipe:", err)
@@@ -710,6 -710,22 +710,22 @@@ func (t *test) run() 
                if tempDirIsGOPATH {
                        cmd.Env = append(cmd.Env, "GOPATH="+t.tempDir)
                }
+               // Put the bin directory of the GOROOT that built this program
+               // first in the path. This ensures that tests that use the "go"
+               // tool use the same one that built this program. This ensures
+               // that if you do "../bin/go run run.go" in this directory, all
+               // the tests that start subprocesses that "go tool compile" or
+               // whatever, use ../bin/go as their go tool, not whatever happens
+               // to be first in the user's path.
+               path := os.Getenv("PATH")
+               newdir := filepath.Join(runtime.GOROOT(), "bin")
+               if path != "" {
+                       path = newdir + string(filepath.ListSeparator) + path
+               } else {
+                       path = newdir
+               }
+               cmd.Env = append(cmd.Env, "PATH="+path)
                cmd.Env = append(cmd.Env, runenv...)
  
                var err error
@@@ -1964,11 -1980,8 +1980,11 @@@ var types2Failures32Bit = setOf
  )
  
  var go118Failures = setOf(
 -      "typeparam/nested.go",     // 1.18 compiler doesn't support function-local types with generics
 -      "typeparam/issue51521.go", // 1.18 compiler produces bad panic message and link error
 +      "typeparam/nested.go",      // 1.18 compiler doesn't support function-local types with generics
 +      "typeparam/issue51521.go",  // 1.18 compiler produces bad panic message and link error
 +      "typeparam/mdempsky/16.go", // 1.18 compiler uses interface shape type in failed type assertions
 +      "typeparam/mdempsky/17.go", // 1.18 compiler mishandles implicit conversions from range loops
 +      "typeparam/mdempsky/18.go", // 1.18 compiler mishandles implicit conversions in select statements
  )
  
  // In all of these cases, the 1.17 compiler reports reasonable errors, but either the
@@@ -1996,10 -2009,18 +2012,10 @@@ var _ = setOf
  )
  
  var unifiedFailures = setOf(
 -      "closure3.go",  // unified IR numbers closures differently than -d=inlfuncswithclosures
 -      "escape4.go",   // unified IR can inline f5 and f6; test doesn't expect this
 -      "inline.go",    // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures
 -      "linkname3.go", // unified IR is missing some linkname errors
 -
 -      "fixedbugs/issue42284.go",  // prints "T(0) does not escape", but test expects "a.I(a.T(0)) does not escape"
 -      "fixedbugs/issue7921.go",   // prints "… escapes to heap", but test expects "string(…) escapes to heap"
 -      "typeparam/issue47631.go",  // unified IR can handle local type declarations
 -      "fixedbugs/issue42058a.go", // unified IR doesn't report channel element too large
 -      "fixedbugs/issue42058b.go", // unified IR doesn't report channel element too large
 -      "fixedbugs/issue49767.go",  // unified IR doesn't report channel element too large
 -      "fixedbugs/issue49814.go",  // unified IR doesn't report array type too large
 +      "closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
 +      "escape4.go",  // unified IR can inline f5 and f6; test doesn't expect this
 +
 +      "typeparam/issue47631.go", // unified IR can handle local type declarations
  )
  
  func setOf(keys ...string) map[string]bool {