1
0
mirror of https://github.com/golang/go synced 2024-11-15 01:20:28 -07:00
go/test/inline_big.go

1030 lines
13 KiB
Go
Raw Normal View History

cmd/compile: set stricter inlining threshold in large functions If we're compiling a large function, be more picky about how big the function we're inlining is. If the function is >5000 nodes, we lower the inlining threshold from a cost of 80 to 20. Turns out reflect.Value's cost is exactly 80. That's the function at issue in #26546. 20 was chosen as a proxy for "inlined body is smaller than the call would be". Simple functions still get inlined, like this one at cost 7: func ifaceIndir(t *rtype) bool { return t.kind&kindDirectIface == 0 } 5000 nodes was chosen as the big function size. Here are all the 5000+ node (~~1000+ lines) functions in the stdlib: 5187 cmd/internal/obj/arm (*ctxt5).asmout 6879 cmd/internal/obj/s390x (*ctxtz).asmout 6567 cmd/internal/obj/ppc64 (*ctxt9).asmout 9643 cmd/internal/obj/arm64 (*ctxt7).asmout 5042 cmd/internal/obj/x86 (*AsmBuf).doasm 8768 cmd/compile/internal/ssa rewriteBlockAMD64 8878 cmd/compile/internal/ssa rewriteBlockARM 8344 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_20 7916 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_30 5427 cmd/compile/internal/ssa rewriteBlockARM64 5126 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_50 6152 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_60 6412 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_70 6486 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_80 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_90 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_100 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_110 6675 cmd/compile/internal/gc typecheck1 5433 cmd/compile/internal/gc walkexpr 14070 cmd/vendor/golang.org/x/arch/arm64/arm64asm decodeArg There are a lot more smaller (~1000 node) functions in the stdlib. The function in #26546 has 12477 nodes. At some point it might be nice to have a better heuristic for "inlined body is smaller than the call", a non-cliff way to scale down the cost as the function gets bigger, doing cheaper inlined calls first, etc. All that can wait for another release. I'd like to do this CL for 1.11. Fixes #26546 Update #17566 Change-Id: Idda13020e46ec2b28d79a17217f44b189f8139ac Reviewed-on: https://go-review.googlesource.com/125516 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-07-23 14:09:48 -06:00
// errorcheck -0 -m=2
// Copyright 2018 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.
// Test that we restrict inlining into very large functions.
// See issue #26546.
package foo
func small(a []int) int { // ERROR "can inline small with cost .* as:.*" "a does not escape"
cmd/compile: set stricter inlining threshold in large functions If we're compiling a large function, be more picky about how big the function we're inlining is. If the function is >5000 nodes, we lower the inlining threshold from a cost of 80 to 20. Turns out reflect.Value's cost is exactly 80. That's the function at issue in #26546. 20 was chosen as a proxy for "inlined body is smaller than the call would be". Simple functions still get inlined, like this one at cost 7: func ifaceIndir(t *rtype) bool { return t.kind&kindDirectIface == 0 } 5000 nodes was chosen as the big function size. Here are all the 5000+ node (~~1000+ lines) functions in the stdlib: 5187 cmd/internal/obj/arm (*ctxt5).asmout 6879 cmd/internal/obj/s390x (*ctxtz).asmout 6567 cmd/internal/obj/ppc64 (*ctxt9).asmout 9643 cmd/internal/obj/arm64 (*ctxt7).asmout 5042 cmd/internal/obj/x86 (*AsmBuf).doasm 8768 cmd/compile/internal/ssa rewriteBlockAMD64 8878 cmd/compile/internal/ssa rewriteBlockARM 8344 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_20 7916 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_30 5427 cmd/compile/internal/ssa rewriteBlockARM64 5126 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_50 6152 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_60 6412 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_70 6486 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_80 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_90 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_100 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_110 6675 cmd/compile/internal/gc typecheck1 5433 cmd/compile/internal/gc walkexpr 14070 cmd/vendor/golang.org/x/arch/arm64/arm64asm decodeArg There are a lot more smaller (~1000 node) functions in the stdlib. The function in #26546 has 12477 nodes. At some point it might be nice to have a better heuristic for "inlined body is smaller than the call", a non-cliff way to scale down the cost as the function gets bigger, doing cheaper inlined calls first, etc. All that can wait for another release. I'd like to do this CL for 1.11. Fixes #26546 Update #17566 Change-Id: Idda13020e46ec2b28d79a17217f44b189f8139ac Reviewed-on: https://go-review.googlesource.com/125516 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-07-23 14:09:48 -06:00
// Cost 16 body (need cost < 20).
// See cmd/compile/internal/gc/inl.go:inlineBigFunction*
return a[0] + a[1] + a[2] + a[3]
}
func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a does not escape"
cmd/compile: set stricter inlining threshold in large functions If we're compiling a large function, be more picky about how big the function we're inlining is. If the function is >5000 nodes, we lower the inlining threshold from a cost of 80 to 20. Turns out reflect.Value's cost is exactly 80. That's the function at issue in #26546. 20 was chosen as a proxy for "inlined body is smaller than the call would be". Simple functions still get inlined, like this one at cost 7: func ifaceIndir(t *rtype) bool { return t.kind&kindDirectIface == 0 } 5000 nodes was chosen as the big function size. Here are all the 5000+ node (~~1000+ lines) functions in the stdlib: 5187 cmd/internal/obj/arm (*ctxt5).asmout 6879 cmd/internal/obj/s390x (*ctxtz).asmout 6567 cmd/internal/obj/ppc64 (*ctxt9).asmout 9643 cmd/internal/obj/arm64 (*ctxt7).asmout 5042 cmd/internal/obj/x86 (*AsmBuf).doasm 8768 cmd/compile/internal/ssa rewriteBlockAMD64 8878 cmd/compile/internal/ssa rewriteBlockARM 8344 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_20 7916 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_30 5427 cmd/compile/internal/ssa rewriteBlockARM64 5126 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_50 6152 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_60 6412 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_70 6486 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_80 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_90 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_100 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_110 6675 cmd/compile/internal/gc typecheck1 5433 cmd/compile/internal/gc walkexpr 14070 cmd/vendor/golang.org/x/arch/arm64/arm64asm decodeArg There are a lot more smaller (~1000 node) functions in the stdlib. The function in #26546 has 12477 nodes. At some point it might be nice to have a better heuristic for "inlined body is smaller than the call", a non-cliff way to scale down the cost as the function gets bigger, doing cheaper inlined calls first, etc. All that can wait for another release. I'd like to do this CL for 1.11. Fixes #26546 Update #17566 Change-Id: Idda13020e46ec2b28d79a17217f44b189f8139ac Reviewed-on: https://go-review.googlesource.com/125516 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-07-23 14:09:48 -06:00
// Cost 32 body (need cost > 20 and cost < 80).
// See cmd/compile/internal/gc/inl.go:inlineBigFunction*
return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
}
func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape" "function f considered 'big'"
cmd/compile: set stricter inlining threshold in large functions If we're compiling a large function, be more picky about how big the function we're inlining is. If the function is >5000 nodes, we lower the inlining threshold from a cost of 80 to 20. Turns out reflect.Value's cost is exactly 80. That's the function at issue in #26546. 20 was chosen as a proxy for "inlined body is smaller than the call would be". Simple functions still get inlined, like this one at cost 7: func ifaceIndir(t *rtype) bool { return t.kind&kindDirectIface == 0 } 5000 nodes was chosen as the big function size. Here are all the 5000+ node (~~1000+ lines) functions in the stdlib: 5187 cmd/internal/obj/arm (*ctxt5).asmout 6879 cmd/internal/obj/s390x (*ctxtz).asmout 6567 cmd/internal/obj/ppc64 (*ctxt9).asmout 9643 cmd/internal/obj/arm64 (*ctxt7).asmout 5042 cmd/internal/obj/x86 (*AsmBuf).doasm 8768 cmd/compile/internal/ssa rewriteBlockAMD64 8878 cmd/compile/internal/ssa rewriteBlockARM 8344 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_20 7916 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_30 5427 cmd/compile/internal/ssa rewriteBlockARM64 5126 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_50 6152 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_60 6412 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_70 6486 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_80 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_90 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_100 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_110 6675 cmd/compile/internal/gc typecheck1 5433 cmd/compile/internal/gc walkexpr 14070 cmd/vendor/golang.org/x/arch/arm64/arm64asm decodeArg There are a lot more smaller (~1000 node) functions in the stdlib. The function in #26546 has 12477 nodes. At some point it might be nice to have a better heuristic for "inlined body is smaller than the call", a non-cliff way to scale down the cost as the function gets bigger, doing cheaper inlined calls first, etc. All that can wait for another release. I'd like to do this CL for 1.11. Fixes #26546 Update #17566 Change-Id: Idda13020e46ec2b28d79a17217f44b189f8139ac Reviewed-on: https://go-review.googlesource.com/125516 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-07-23 14:09:48 -06:00
// Add lots of nodes to f's body. We need >5000.
// See cmd/compile/internal/gc/inl.go:inlineBigFunction*
a[0] = 0
a[1] = 0
a[2] = 0
a[3] = 0
a[4] = 0
a[5] = 0
a[6] = 0
a[7] = 0
a[8] = 0
a[9] = 0
a[10] = 0
a[11] = 0
a[12] = 0
a[13] = 0
a[14] = 0
a[15] = 0
a[16] = 0
a[17] = 0
a[18] = 0
a[19] = 0
a[20] = 0
a[21] = 0
a[22] = 0
a[23] = 0
a[24] = 0
a[25] = 0
a[26] = 0
a[27] = 0
a[28] = 0
a[29] = 0
a[30] = 0
a[31] = 0
a[32] = 0
a[33] = 0
a[34] = 0
a[35] = 0
a[36] = 0
a[37] = 0
a[38] = 0
a[39] = 0
a[40] = 0
a[41] = 0
a[42] = 0
a[43] = 0
a[44] = 0
a[45] = 0
a[46] = 0
a[47] = 0
a[48] = 0
a[49] = 0
a[50] = 0
a[51] = 0
a[52] = 0
a[53] = 0
a[54] = 0
a[55] = 0
a[56] = 0
a[57] = 0
a[58] = 0
a[59] = 0
a[60] = 0
a[61] = 0
a[62] = 0
a[63] = 0
a[64] = 0
a[65] = 0
a[66] = 0
a[67] = 0
a[68] = 0
a[69] = 0
a[70] = 0
a[71] = 0
a[72] = 0
a[73] = 0
a[74] = 0
a[75] = 0
a[76] = 0
a[77] = 0
a[78] = 0
a[79] = 0
a[80] = 0
a[81] = 0
a[82] = 0
a[83] = 0
a[84] = 0
a[85] = 0
a[86] = 0
a[87] = 0
a[88] = 0
a[89] = 0
a[90] = 0
a[91] = 0
a[92] = 0
a[93] = 0
a[94] = 0
a[95] = 0
a[96] = 0
a[97] = 0
a[98] = 0
a[99] = 0
a[100] = 0
a[101] = 0
a[102] = 0
a[103] = 0
a[104] = 0
a[105] = 0
a[106] = 0
a[107] = 0
a[108] = 0
a[109] = 0
a[110] = 0
a[111] = 0
a[112] = 0
a[113] = 0
a[114] = 0
a[115] = 0
a[116] = 0
a[117] = 0
a[118] = 0
a[119] = 0
a[120] = 0
a[121] = 0
a[122] = 0
a[123] = 0
a[124] = 0
a[125] = 0
a[126] = 0
a[127] = 0
a[128] = 0
a[129] = 0
a[130] = 0
a[131] = 0
a[132] = 0
a[133] = 0
a[134] = 0
a[135] = 0
a[136] = 0
a[137] = 0
a[138] = 0
a[139] = 0
a[140] = 0
a[141] = 0
a[142] = 0
a[143] = 0
a[144] = 0
a[145] = 0
a[146] = 0
a[147] = 0
a[148] = 0
a[149] = 0
a[150] = 0
a[151] = 0
a[152] = 0
a[153] = 0
a[154] = 0
a[155] = 0
a[156] = 0
a[157] = 0
a[158] = 0
a[159] = 0
a[160] = 0
a[161] = 0
a[162] = 0
a[163] = 0
a[164] = 0
a[165] = 0
a[166] = 0
a[167] = 0
a[168] = 0
a[169] = 0
a[170] = 0
a[171] = 0
a[172] = 0
a[173] = 0
a[174] = 0
a[175] = 0
a[176] = 0
a[177] = 0
a[178] = 0
a[179] = 0
a[180] = 0
a[181] = 0
a[182] = 0
a[183] = 0
a[184] = 0
a[185] = 0
a[186] = 0
a[187] = 0
a[188] = 0
a[189] = 0
a[190] = 0
a[191] = 0
a[192] = 0
a[193] = 0
a[194] = 0
a[195] = 0
a[196] = 0
a[197] = 0
a[198] = 0
a[199] = 0
a[200] = 0
a[201] = 0
a[202] = 0
a[203] = 0
a[204] = 0
a[205] = 0
a[206] = 0
a[207] = 0
a[208] = 0
a[209] = 0
a[210] = 0
a[211] = 0
a[212] = 0
a[213] = 0
a[214] = 0
a[215] = 0
a[216] = 0
a[217] = 0
a[218] = 0
a[219] = 0
a[220] = 0
a[221] = 0
a[222] = 0
a[223] = 0
a[224] = 0
a[225] = 0
a[226] = 0
a[227] = 0
a[228] = 0
a[229] = 0
a[230] = 0
a[231] = 0
a[232] = 0
a[233] = 0
a[234] = 0
a[235] = 0
a[236] = 0
a[237] = 0
a[238] = 0
a[239] = 0
a[240] = 0
a[241] = 0
a[242] = 0
a[243] = 0
a[244] = 0
a[245] = 0
a[246] = 0
a[247] = 0
a[248] = 0
a[249] = 0
a[250] = 0
a[251] = 0
a[252] = 0
a[253] = 0
a[254] = 0
a[255] = 0
a[256] = 0
a[257] = 0
a[258] = 0
a[259] = 0
a[260] = 0
a[261] = 0
a[262] = 0
a[263] = 0
a[264] = 0
a[265] = 0
a[266] = 0
a[267] = 0
a[268] = 0
a[269] = 0
a[270] = 0
a[271] = 0
a[272] = 0
a[273] = 0
a[274] = 0
a[275] = 0
a[276] = 0
a[277] = 0
a[278] = 0
a[279] = 0
a[280] = 0
a[281] = 0
a[282] = 0
a[283] = 0
a[284] = 0
a[285] = 0
a[286] = 0
a[287] = 0
a[288] = 0
a[289] = 0
a[290] = 0
a[291] = 0
a[292] = 0
a[293] = 0
a[294] = 0
a[295] = 0
a[296] = 0
a[297] = 0
a[298] = 0
a[299] = 0
a[300] = 0
a[301] = 0
a[302] = 0
a[303] = 0
a[304] = 0
a[305] = 0
a[306] = 0
a[307] = 0
a[308] = 0
a[309] = 0
a[310] = 0
a[311] = 0
a[312] = 0
a[313] = 0
a[314] = 0
a[315] = 0
a[316] = 0
a[317] = 0
a[318] = 0
a[319] = 0
a[320] = 0
a[321] = 0
a[322] = 0
a[323] = 0
a[324] = 0
a[325] = 0
a[326] = 0
a[327] = 0
a[328] = 0
a[329] = 0
a[330] = 0
a[331] = 0
a[332] = 0
a[333] = 0
a[334] = 0
a[335] = 0
a[336] = 0
a[337] = 0
a[338] = 0
a[339] = 0
a[340] = 0
a[341] = 0
a[342] = 0
a[343] = 0
a[344] = 0
a[345] = 0
a[346] = 0
a[347] = 0
a[348] = 0
a[349] = 0
a[350] = 0
a[351] = 0
a[352] = 0
a[353] = 0
a[354] = 0
a[355] = 0
a[356] = 0
a[357] = 0
a[358] = 0
a[359] = 0
a[360] = 0
a[361] = 0
a[362] = 0
a[363] = 0
a[364] = 0
a[365] = 0
a[366] = 0
a[367] = 0
a[368] = 0
a[369] = 0
a[370] = 0
a[371] = 0
a[372] = 0
a[373] = 0
a[374] = 0
a[375] = 0
a[376] = 0
a[377] = 0
a[378] = 0
a[379] = 0
a[380] = 0
a[381] = 0
a[382] = 0
a[383] = 0
a[384] = 0
a[385] = 0
a[386] = 0
a[387] = 0
a[388] = 0
a[389] = 0
a[390] = 0
a[391] = 0
a[392] = 0
a[393] = 0
a[394] = 0
a[395] = 0
a[396] = 0
a[397] = 0
a[398] = 0
a[399] = 0
a[400] = 0
a[401] = 0
a[402] = 0
a[403] = 0
a[404] = 0
a[405] = 0
a[406] = 0
a[407] = 0
a[408] = 0
a[409] = 0
a[410] = 0
a[411] = 0
a[412] = 0
a[413] = 0
a[414] = 0
a[415] = 0
a[416] = 0
a[417] = 0
a[418] = 0
a[419] = 0
a[420] = 0
a[421] = 0
a[422] = 0
a[423] = 0
a[424] = 0
a[425] = 0
a[426] = 0
a[427] = 0
a[428] = 0
a[429] = 0
a[430] = 0
a[431] = 0
a[432] = 0
a[433] = 0
a[434] = 0
a[435] = 0
a[436] = 0
a[437] = 0
a[438] = 0
a[439] = 0
a[440] = 0
a[441] = 0
a[442] = 0
a[443] = 0
a[444] = 0
a[445] = 0
a[446] = 0
a[447] = 0
a[448] = 0
a[449] = 0
a[450] = 0
a[451] = 0
a[452] = 0
a[453] = 0
a[454] = 0
a[455] = 0
a[456] = 0
a[457] = 0
a[458] = 0
a[459] = 0
a[460] = 0
a[461] = 0
a[462] = 0
a[463] = 0
a[464] = 0
a[465] = 0
a[466] = 0
a[467] = 0
a[468] = 0
a[469] = 0
a[470] = 0
a[471] = 0
a[472] = 0
a[473] = 0
a[474] = 0
a[475] = 0
a[476] = 0
a[477] = 0
a[478] = 0
a[479] = 0
a[480] = 0
a[481] = 0
a[482] = 0
a[483] = 0
a[484] = 0
a[485] = 0
a[486] = 0
a[487] = 0
a[488] = 0
a[489] = 0
a[490] = 0
a[491] = 0
a[492] = 0
a[493] = 0
a[494] = 0
a[495] = 0
a[496] = 0
a[497] = 0
a[498] = 0
a[499] = 0
a[500] = 0
a[501] = 0
a[502] = 0
a[503] = 0
a[504] = 0
a[505] = 0
a[506] = 0
a[507] = 0
a[508] = 0
a[509] = 0
a[510] = 0
a[511] = 0
a[512] = 0
a[513] = 0
a[514] = 0
a[515] = 0
a[516] = 0
a[517] = 0
a[518] = 0
a[519] = 0
a[520] = 0
a[521] = 0
a[522] = 0
a[523] = 0
a[524] = 0
a[525] = 0
a[526] = 0
a[527] = 0
a[528] = 0
a[529] = 0
a[530] = 0
a[531] = 0
a[532] = 0
a[533] = 0
a[534] = 0
a[535] = 0
a[536] = 0
a[537] = 0
a[538] = 0
a[539] = 0
a[540] = 0
a[541] = 0
a[542] = 0
a[543] = 0
a[544] = 0
a[545] = 0
a[546] = 0
a[547] = 0
a[548] = 0
a[549] = 0
a[550] = 0
a[551] = 0
a[552] = 0
a[553] = 0
a[554] = 0
a[555] = 0
a[556] = 0
a[557] = 0
a[558] = 0
a[559] = 0
a[560] = 0
a[561] = 0
a[562] = 0
a[563] = 0
a[564] = 0
a[565] = 0
a[566] = 0
a[567] = 0
a[568] = 0
a[569] = 0
a[570] = 0
a[571] = 0
a[572] = 0
a[573] = 0
a[574] = 0
a[575] = 0
a[576] = 0
a[577] = 0
a[578] = 0
a[579] = 0
a[580] = 0
a[581] = 0
a[582] = 0
a[583] = 0
a[584] = 0
a[585] = 0
a[586] = 0
a[587] = 0
a[588] = 0
a[589] = 0
a[590] = 0
a[591] = 0
a[592] = 0
a[593] = 0
a[594] = 0
a[595] = 0
a[596] = 0
a[597] = 0
a[598] = 0
a[599] = 0
a[600] = 0
a[601] = 0
a[602] = 0
a[603] = 0
a[604] = 0
a[605] = 0
a[606] = 0
a[607] = 0
a[608] = 0
a[609] = 0
a[610] = 0
a[611] = 0
a[612] = 0
a[613] = 0
a[614] = 0
a[615] = 0
a[616] = 0
a[617] = 0
a[618] = 0
a[619] = 0
a[620] = 0
a[621] = 0
a[622] = 0
a[623] = 0
a[624] = 0
a[625] = 0
a[626] = 0
a[627] = 0
a[628] = 0
a[629] = 0
a[630] = 0
a[631] = 0
a[632] = 0
a[633] = 0
a[634] = 0
a[635] = 0
a[636] = 0
a[637] = 0
a[638] = 0
a[639] = 0
a[640] = 0
a[641] = 0
a[642] = 0
a[643] = 0
a[644] = 0
a[645] = 0
a[646] = 0
a[647] = 0
a[648] = 0
a[649] = 0
a[650] = 0
a[651] = 0
a[652] = 0
a[653] = 0
a[654] = 0
a[655] = 0
a[656] = 0
a[657] = 0
a[658] = 0
a[659] = 0
a[660] = 0
a[661] = 0
a[662] = 0
a[663] = 0
a[664] = 0
a[665] = 0
a[666] = 0
a[667] = 0
a[668] = 0
a[669] = 0
a[670] = 0
a[671] = 0
a[672] = 0
a[673] = 0
a[674] = 0
a[675] = 0
a[676] = 0
a[677] = 0
a[678] = 0
a[679] = 0
a[680] = 0
a[681] = 0
a[682] = 0
a[683] = 0
a[684] = 0
a[685] = 0
a[686] = 0
a[687] = 0
a[688] = 0
a[689] = 0
a[690] = 0
a[691] = 0
a[692] = 0
a[693] = 0
a[694] = 0
a[695] = 0
a[696] = 0
a[697] = 0
a[698] = 0
a[699] = 0
a[700] = 0
a[701] = 0
a[702] = 0
a[703] = 0
a[704] = 0
a[705] = 0
a[706] = 0
a[707] = 0
a[708] = 0
a[709] = 0
a[710] = 0
a[711] = 0
a[712] = 0
a[713] = 0
a[714] = 0
a[715] = 0
a[716] = 0
a[717] = 0
a[718] = 0
a[719] = 0
a[720] = 0
a[721] = 0
a[722] = 0
a[723] = 0
a[724] = 0
a[725] = 0
a[726] = 0
a[727] = 0
a[728] = 0
a[729] = 0
a[730] = 0
a[731] = 0
a[732] = 0
a[733] = 0
a[734] = 0
a[735] = 0
a[736] = 0
a[737] = 0
a[738] = 0
a[739] = 0
a[740] = 0
a[741] = 0
a[742] = 0
a[743] = 0
a[744] = 0
a[745] = 0
a[746] = 0
a[747] = 0
a[748] = 0
a[749] = 0
a[750] = 0
a[751] = 0
a[752] = 0
a[753] = 0
a[754] = 0
a[755] = 0
a[756] = 0
a[757] = 0
a[758] = 0
a[759] = 0
a[760] = 0
a[761] = 0
a[762] = 0
a[763] = 0
a[764] = 0
a[765] = 0
a[766] = 0
a[767] = 0
a[768] = 0
a[769] = 0
a[770] = 0
a[771] = 0
a[772] = 0
a[773] = 0
a[774] = 0
a[775] = 0
a[776] = 0
a[777] = 0
a[778] = 0
a[779] = 0
a[780] = 0
a[781] = 0
a[782] = 0
a[783] = 0
a[784] = 0
a[785] = 0
a[786] = 0
a[787] = 0
a[788] = 0
a[789] = 0
a[790] = 0
a[791] = 0
a[792] = 0
a[793] = 0
a[794] = 0
a[795] = 0
a[796] = 0
a[797] = 0
a[798] = 0
a[799] = 0
a[800] = 0
a[801] = 0
a[802] = 0
a[803] = 0
a[804] = 0
a[805] = 0
a[806] = 0
a[807] = 0
a[808] = 0
a[809] = 0
a[810] = 0
a[811] = 0
a[812] = 0
a[813] = 0
a[814] = 0
a[815] = 0
a[816] = 0
a[817] = 0
a[818] = 0
a[819] = 0
a[820] = 0
a[821] = 0
a[822] = 0
a[823] = 0
a[824] = 0
a[825] = 0
a[826] = 0
a[827] = 0
a[828] = 0
a[829] = 0
a[830] = 0
a[831] = 0
a[832] = 0
a[833] = 0
a[834] = 0
a[835] = 0
a[836] = 0
a[837] = 0
a[838] = 0
a[839] = 0
a[840] = 0
a[841] = 0
a[842] = 0
a[843] = 0
a[844] = 0
a[845] = 0
a[846] = 0
a[847] = 0
a[848] = 0
a[849] = 0
a[850] = 0
a[851] = 0
a[852] = 0
a[853] = 0
a[854] = 0
a[855] = 0
a[856] = 0
a[857] = 0
a[858] = 0
a[859] = 0
a[860] = 0
a[861] = 0
a[862] = 0
a[863] = 0
a[864] = 0
a[865] = 0
a[866] = 0
a[867] = 0
a[868] = 0
a[869] = 0
a[870] = 0
a[871] = 0
a[872] = 0
a[873] = 0
a[874] = 0
a[875] = 0
a[876] = 0
a[877] = 0
a[878] = 0
a[879] = 0
a[880] = 0
a[881] = 0
a[882] = 0
a[883] = 0
a[884] = 0
a[885] = 0
a[886] = 0
a[887] = 0
a[888] = 0
a[889] = 0
a[890] = 0
a[891] = 0
a[892] = 0
a[893] = 0
a[894] = 0
a[895] = 0
a[896] = 0
a[897] = 0
a[898] = 0
a[899] = 0
a[900] = 0
a[901] = 0
a[902] = 0
a[903] = 0
a[904] = 0
a[905] = 0
a[906] = 0
a[907] = 0
a[908] = 0
a[909] = 0
a[910] = 0
a[911] = 0
a[912] = 0
a[913] = 0
a[914] = 0
a[915] = 0
a[916] = 0
a[917] = 0
a[918] = 0
a[919] = 0
a[920] = 0
a[921] = 0
a[922] = 0
a[923] = 0
a[924] = 0
a[925] = 0
a[926] = 0
a[927] = 0
a[928] = 0
a[929] = 0
a[930] = 0
a[931] = 0
a[932] = 0
a[933] = 0
a[934] = 0
a[935] = 0
a[936] = 0
a[937] = 0
a[938] = 0
a[939] = 0
a[940] = 0
a[941] = 0
a[942] = 0
a[943] = 0
a[944] = 0
a[945] = 0
a[946] = 0
a[947] = 0
a[948] = 0
a[949] = 0
a[950] = 0
a[951] = 0
a[952] = 0
a[953] = 0
a[954] = 0
a[955] = 0
a[956] = 0
a[957] = 0
a[958] = 0
a[959] = 0
a[960] = 0
a[961] = 0
a[962] = 0
a[963] = 0
a[964] = 0
a[965] = 0
a[966] = 0
a[967] = 0
a[968] = 0
a[969] = 0
a[970] = 0
a[971] = 0
a[972] = 0
a[973] = 0
a[974] = 0
a[975] = 0
a[976] = 0
a[977] = 0
a[978] = 0
a[979] = 0
a[980] = 0
a[981] = 0
a[982] = 0
a[983] = 0
a[984] = 0
a[985] = 0
a[986] = 0
a[987] = 0
a[988] = 0
a[989] = 0
a[990] = 0
a[991] = 0
a[992] = 0
a[993] = 0
a[994] = 0
a[995] = 0
a[996] = 0
a[997] = 0
a[998] = 0
a[999] = 0
x := small(a) // ERROR "inlining call to small"
cmd/compile: set stricter inlining threshold in large functions If we're compiling a large function, be more picky about how big the function we're inlining is. If the function is >5000 nodes, we lower the inlining threshold from a cost of 80 to 20. Turns out reflect.Value's cost is exactly 80. That's the function at issue in #26546. 20 was chosen as a proxy for "inlined body is smaller than the call would be". Simple functions still get inlined, like this one at cost 7: func ifaceIndir(t *rtype) bool { return t.kind&kindDirectIface == 0 } 5000 nodes was chosen as the big function size. Here are all the 5000+ node (~~1000+ lines) functions in the stdlib: 5187 cmd/internal/obj/arm (*ctxt5).asmout 6879 cmd/internal/obj/s390x (*ctxtz).asmout 6567 cmd/internal/obj/ppc64 (*ctxt9).asmout 9643 cmd/internal/obj/arm64 (*ctxt7).asmout 5042 cmd/internal/obj/x86 (*AsmBuf).doasm 8768 cmd/compile/internal/ssa rewriteBlockAMD64 8878 cmd/compile/internal/ssa rewriteBlockARM 8344 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_20 7916 cmd/compile/internal/ssa rewriteValueARM64_OpARM64OR_30 5427 cmd/compile/internal/ssa rewriteBlockARM64 5126 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_50 6152 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_60 6412 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_70 6486 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_80 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_90 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_100 6534 cmd/compile/internal/ssa rewriteValuePPC64_OpPPC64OR_110 6675 cmd/compile/internal/gc typecheck1 5433 cmd/compile/internal/gc walkexpr 14070 cmd/vendor/golang.org/x/arch/arm64/arm64asm decodeArg There are a lot more smaller (~1000 node) functions in the stdlib. The function in #26546 has 12477 nodes. At some point it might be nice to have a better heuristic for "inlined body is smaller than the call", a non-cliff way to scale down the cost as the function gets bigger, doing cheaper inlined calls first, etc. All that can wait for another release. I'd like to do this CL for 1.11. Fixes #26546 Update #17566 Change-Id: Idda13020e46ec2b28d79a17217f44b189f8139ac Reviewed-on: https://go-review.googlesource.com/125516 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-07-23 14:09:48 -06:00
y := medium(a) // The crux of this test: medium is not inlined.
return x + y
}