Skip to content

Commit 09d4455

Browse files
committed
cmd/compile: enable inlining variadic functions
As a side effect of working on mid-stack inlining, we've fixed support for inlining variadic functions. Might as well enable it. Change-Id: I7f555f8b941969791db7eb598c0b49f6dc0820aa Reviewed-on: https://go-review.googlesource.com/100456 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent c74aa39 commit 09d4455

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

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

+1-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// 0: disabled
1414
// 1: 80-nodes leaf functions, oneliners, lazy typechecking (default)
1515
// 2: (unassigned)
16-
// 3: allow variadic functions
16+
// 3: (unassigned)
1717
// 4: allow non-leaf functions
1818
//
1919
// At some point this may get another default and become switch-offable with -N.
@@ -23,9 +23,6 @@
2323
//
2424
// The debug['m'] flag enables diagnostic output. a single -m is useful for verifying
2525
// which calls get inlined or not, more is for debugging, and may go away at any point.
26-
//
27-
// TODO:
28-
// - inline functions with ... args
2926

3027
package gc
3128

@@ -141,17 +138,6 @@ func caninl(fn *Node) {
141138
Fatalf("caninl on non-typechecked function %v", fn)
142139
}
143140

144-
// can't handle ... args yet
145-
if Debug['l'] < 3 {
146-
f := fn.Type.Params().Fields()
147-
if len := f.Len(); len > 0 {
148-
if t := f.Index(len - 1); t.Isddd() {
149-
reason = "has ... args"
150-
return
151-
}
152-
}
153-
}
154-
155141
// Runtime package must not be instrumented.
156142
// Instrument skips runtime package. However, some runtime code can be
157143
// inlined into other packages and instrumented there. To avoid this,

test/inline_variadic.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// errorcheck -0 -m -l=3
1+
// errorcheck -0 -m
22

33
// Copyright 2016 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style
55
// license that can be found in the LICENSE file.
66

7-
// Test more aggressive inlining (-l=3 allows variadic functions)
7+
// Test inlining of variadic functions.
88
// See issue #18116.
99

1010
package foo

0 commit comments

Comments
 (0)