Flag.LinkShared = &Ctxt.Flag_linkshared
Flag.Shared = &Ctxt.Flag_shared
Flag.WB = true
+ Debug.InlFuncsWithClosures = 1
Flag.Cfg.ImportMap = make(map[string]string)
return true
case ir.OCLOSURE:
- if base.Debug.InlFuncsWithClosures == 0 {
- // TODO(danscales): change default of InlFuncsWithClosures
- // to 1 when #44370 is fixed
+ if base.Debug.InlFuncsWithClosures == 0 || base.Flag.G > 0 {
v.reason = "not inlining functions with closures"
return true
}
func ComputeAddrtaken(top []ir.Node) {
for _, n := range top {
- ir.Visit(n, func(n ir.Node) {
+ var doVisit func(n ir.Node)
+ doVisit = func(n ir.Node) {
if n.Op() == ir.OADDR {
if x := ir.OuterValue(n.(*ir.AddrExpr).X); x.Op() == ir.ONAME {
x.Name().SetAddrtaken(true)
}
}
}
- })
+ if n.Op() == ir.OCLOSURE {
+ ir.VisitList(n.(*ir.ClosureExpr).Func.Body, doVisit)
+ }
+ }
+ ir.Visit(n, doVisit)
}
}
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+package a
+
+// A StoppableWaitGroup waits for a collection of goroutines to finish.
+type StoppableWaitGroup struct {
+ // i is the internal counter which can store tolerate negative values
+ // as opposed the golang's library WaitGroup.
+ i *int64
+}
+
+// NewStoppableWaitGroup returns a new StoppableWaitGroup. When the 'Stop' is
+// executed, following 'Add()' calls won't have any effect.
+func NewStoppableWaitGroup() *StoppableWaitGroup {
+ return &StoppableWaitGroup{
+ i: func() *int64 { i := int64(0); return &i }(),
+ }
+}
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+package b
+
+import "./a"
+
+func JoinClusterServices() {
+ _ = a.NewStoppableWaitGroup()
+}
--- /dev/null
+// compiledir
+
+// Copyright 2021 The Go Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+package ignored