1
0
mirror of https://github.com/golang/go synced 2024-09-23 21:30:18 -06:00
go/test
Matthew Dempsky 35693d037f cmd/compile: fix miscompilation during inlining
When inlining a function call expression, it's possible that the
function callee subexpression has side effects that need to be
preserved. This used to not be an issue, because inlining wouldn't
recognize these as inlinable anyway. But golang.org/cl/266199 extended
the inlining logic to recognize more cases, but did not notice that
the actual inlining code was discarding side effects.

Issue identified by danscales@.

Fixes #42703.

Change-Id: I95f8fc076b6ca4e9362e80ec26dad9d87a5bc44a
Reviewed-on: https://go-review.googlesource.com/c/go/+/271219
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-11-18 22:24:21 +00:00
..
alias3.dir
bench
chan test/chan: fix trivial typos 2020-03-25 22:22:20 +00:00
closure3.dir cmd/compile: allow inlining of "for" loops 2020-10-15 18:26:33 +00:00
codegen cmd/compile: fix rules regression with shifts on PPC64 2020-11-17 13:20:20 +00:00
ddd2.dir
dwarf
fixedbugs cmd/compile: fix miscompilation during inlining 2020-11-18 22:24:21 +00:00
import2.dir
import4.dir
interface test: add tests for runtime.itab.init 2019-11-06 09:09:59 +00:00
intrinsic.dir
ken all: fix typos 2019-09-08 17:28:20 +00:00
linkname.dir cmd/compile: trim function name prefix from escape diagnostics 2019-09-16 15:30:51 +00:00
method4.dir
oldescape_linkname.dir
retjmp.dir
runtime
stress
syntax cmd/compile/internal/syntax: better error when an assignment is used in value context 2020-02-21 22:57:52 +00:00
uintptrescapes.dir
64bit.go
235.go
alg.go
alias1.go
alias2.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
alias3.go
alias.go
align.go
append1.go
append.go
args.go
armimm.go
assign1.go
assign.go
atomicload.go
bigalg.go
bigmap.go
blank1.go test, test/fixedbugs, crypto/x509, go/internal/gccgoimporter: fix typos 2020-03-29 17:12:56 +00:00
blank.go
bom.go
bombad.go
bounds.go cmd/compile: defer lowering OANDNOT until SSA 2020-10-27 03:11:45 +00:00
cannotassign.go cmd/compile: be more specific in cannot assign errors 2020-09-16 20:04:58 +00:00
chancap.go
chanlinear.go test, test/fixedbugs, crypto/x509, go/internal/gccgoimporter: fix typos 2020-03-29 17:12:56 +00:00
char_lit1.go
char_lit.go
checkbce.go
clearfat.go
closedchan.go
closure1.go
closure2.go all: fix typos 2019-09-08 17:28:20 +00:00
closure3.go
closure4.go
closure.go
cmp6.go
cmp.go
cmplx.go
cmplxdivide1.go
cmplxdivide.c
cmplxdivide.go
complit1.go cmd/compile: simplify OPTRLIT handling 2019-09-26 18:45:53 +00:00
complit.go
compos.go
const1.go
const2.go
const3.go
const4.go
const5.go
const6.go
const.go cmd/compile: apply constant folding to ORUNESTR 2019-09-26 23:54:29 +00:00
convert1.go
convert2.go
convert3.go
convert.go
convlit1.go
convlit.go
convT2X.go
copy1.go
copy.go
crlf.go
ddd1.go cmd/compile: don't report not enough args error if call is undefined 2020-09-12 08:50:45 +00:00
ddd2.go
ddd.go
decl.go
declbad.go
defer.go
defererrcheck.go test: re-enable open-coded defer test on riscv64 2020-02-26 16:54:17 +00:00
deferfin.go
defernil.go cmd/compile: on Wasm and AIX, let deferred nil function panic at invocation 2019-10-16 00:05:37 +00:00
deferprint.go
deferprint.out
devirt.go cmd/compile: debug rewrite 2020-04-13 21:56:15 +00:00
directive.go cmd/compile: reject misplaced go:build comments 2020-10-13 01:16:45 +00:00
divide.go
divmod.go
empty.go
env.go
eof1.go
eof.go
escape2.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape2n.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape3.go
escape4.go
escape5.go cmd/compile: add failing test case for #24305 2020-08-15 03:09:52 +00:00
escape_array.go cmd/compile: trim function name prefix from escape diagnostics 2019-09-16 15:30:51 +00:00
escape_calls.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_closure.go cmd/compile: improve escape analysis of known calls 2020-10-15 18:26:06 +00:00
escape_field.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_goto.go
escape_hash_maphash.go hash/maphash: mark call into runtime hash function as not escaping 2019-11-16 20:31:45 +00:00
escape_iface.go cmd/compile: fix devirtualization of promoted interface methods 2020-10-30 00:47:37 +00:00
escape_indir.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_level.go
escape_map.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_param.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_runtime_atomic.go
escape_selfassign.go
escape_slice.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_struct_param1.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_struct_param2.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_struct_return.go
escape_sync_atomic.go
escape_unsafe.go
escape.go
fibo.go
finprofiled.go all: fix typos 2019-09-08 17:28:20 +00:00
float_lit2.go
float_lit3.go
float_lit.go
floatcmp.go
for.go
func1.go
func2.go
func3.go
func4.go
func5.go
func6.go
func7.go
func8.go
func.go
funcdup2.go
funcdup.go
gc1.go
gc2.go
gc.go
gcgort.go
gcstring.go
goprint.go test: adjust a test to work with js/wasm's background goroutine 2019-10-10 19:38:06 +00:00
goprint.out
goto.go
heapsampling.go
helloworld.go
helloworld.out
if.go
import1.go
import2.go
import4.go
import5.go
import6.go
import.go
index0.go
index1.go
index2.go
index.go all: fix typos 2019-09-08 17:28:20 +00:00
indirect1.go
indirect.go
init1.go
init.go
initcomma.go
initempty.go cmd/compile: add test for skipping empty init functions 2019-11-04 20:19:15 +00:00
initialize.go
initializerr.go
initloop.go
inline_big.go cmd/compile: output cost while inlining function with Debug['m'] > 1 2020-02-26 14:44:24 +00:00
inline_caller.go
inline_callers.go
inline_literal.go
inline_math_bits_rotate.go
inline_sync.go test: re-enable atomic intrinsic related tests on riscv64 2020-03-25 01:11:15 +00:00
inline_variadic.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
inline.go cmd/compile: support inlining of type switches 2020-11-06 20:49:11 +00:00
int_lit.go
intcvt.go
intrinsic_atomic.go test: re-enable atomic intrinsic related tests on riscv64 2020-03-25 01:11:15 +00:00
intrinsic.go
iota.go
label1.go
label.go
linkmain_run.go test: avoid writing temporary files to GOROOT 2019-11-18 14:40:07 +00:00
linkmain.go
linkname.go
linkobj.go
linkx_run.go cmd/compile: don't statically copy string-typed variables 2019-10-03 18:08:32 +00:00
linkx.go [dev.link] all: clean up some TODOs 2019-11-01 20:13:05 +00:00
literal2.go
literal.go
live1.go
live2.go
live_syscall.go cmd/compile: trim function name prefix from escape diagnostics 2019-09-16 15:30:51 +00:00
live.go cmd/compile,cmd/link: fix and re-enable open-coded defers on riscv64 2020-01-29 16:34:44 +00:00
locklinear.go
loopbce.go cmd/compile: detect indvars that are bound by other indvars 2019-09-26 18:47:12 +00:00
makechan.go test: remove duplicate code from makechan/makemap 2020-04-19 07:51:23 +00:00
makemap.go test: remove duplicate code from makechan/makemap 2020-04-19 07:51:23 +00:00
makenew.go
makeslice.go cmd/compile: optimize make+copy pattern to avoid memclr 2020-05-07 17:50:24 +00:00
mallocfin.go
map1.go
map.go
mapclear.go
maplinear.go
mergemul.go
method1.go
method2.go
method3.go
method4.go
method5.go
method6.go
method7.go
method.go
named1.go
named.go
nil.go
nilcheck.go
nilptr2.go
nilptr3.go
nilptr4.go
nilptr5_aix.go
nilptr5_wasm.go
nilptr5.go
nilptr_aix.go
nilptr.go cmd/dist: enable more tests on macOS/ARM64 2020-10-06 21:55:49 +00:00
nosplit.go runtime: static lock ranking for the runtime (enabled by GOEXPERIMENT) 2020-04-07 21:51:03 +00:00
notinheap2.go cmd/compile: propagate go:notinheap implicitly 2020-09-17 19:35:53 +00:00
notinheap3.go
notinheap.go cmd/compile: propagate go:notinheap implicitly 2020-09-17 19:35:53 +00:00
nowritebarrier.go cmd/compile: allow mid-stack inlining when there is a cycle of recursion 2020-04-03 21:43:52 +00:00
nul1.go
opt_branchlikely.go all: fix typos 2019-09-08 17:28:20 +00:00
parentype.go
peano.go
phiopt.go
print.go
print.out
printbig.go
printbig.out
prove.go cmd/compile: check indirect connection between if block and phi block in addLocalInductiveFacts 2020-11-07 07:33:23 +00:00
range.go
README.md test: document specifying individual test files as operands 2020-08-28 21:23:32 +00:00
recover1.go
recover2.go
recover3.go
recover4.go
recover5.go
recover.go
reflectmethod1.go
reflectmethod2.go
reflectmethod3.go
reflectmethod4.go
reflectmethod5.go cmd/compile: when marking REFLECTMETHOD, check for reflect package itself 2020-04-19 03:12:32 +00:00
reflectmethod6.go cmd/compile: when marking REFLECTMETHOD, check for reflect package itself 2020-04-19 03:12:32 +00:00
rename1.go
rename.go
reorder2.go
reorder.go
retjmp.go
return.go
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rotate.go
run.go all: implement GO386=softfloat 2020-10-06 22:49:38 +00:00
rune.go
runtime.go cmd/compile: report error for unexported name only once 2020-08-25 16:06:36 +00:00
shift1.go
shift2.go
sieve.go
sigchld.go
sigchld.out
simassign.go
sinit_run.go test: avoid writing temporary files to GOROOT 2019-11-18 14:40:07 +00:00
sinit.go
sizeof.go
slice3.go
slice3err.go
slicecap.go
sliceopt.go
solitaire.go
stack.go
stackobj2.go
stackobj3.go
stackobj.go
strcopy.go
strength.go all: fix typos 2019-09-08 17:28:20 +00:00
string_lit.go
stringrange.go
struct0.go
switch2.go
switch3.go
switch4.go
switch5.go
switch6.go
switch7.go
switch.go
tinyfin.go
torture.go
turing.go
typecheck.go test: add copyright notice to typecheck.go 2020-04-17 13:30:49 +00:00
typecheckloop.go
typeswitch1.go
typeswitch2.go cmd/compile: move duplicate type-case checking into typecheck 2019-09-11 23:33:11 +00:00
typeswitch2b.go cmd/compile/internal/gc: reword "declared and not used" error message 2019-10-28 23:34:13 +00:00
typeswitch3.go
typeswitch.go
uintptrescapes2.go cmd/compile: fix //go:uintptrescapes for basic method calls 2019-11-05 00:26:30 +00:00
uintptrescapes3.go cmd/compile: fix //go:uintptrescapes for basic method calls 2019-11-05 00:26:30 +00:00
uintptrescapes.go
undef.go
utf.go
varerr.go
varinit.go
winbatch.go all: treat all files as binary, but check in .bat with CRLF 2020-06-08 15:31:43 +00:00
writebarrier.go cmd/compile: improve generated code for concrete cases in type switches 2020-04-14 17:34:31 +00:00
zerodivide.go

The test directory contains tests of the Go tool chain and runtime. It includes black box tests, regression tests, and error output tests. They are run as part of all.bash.

To run just these tests, execute:

../bin/go run run.go

To run just tests from specified files in this directory, execute:

../bin/go run run.go -- file1.go file2.go ...

Standard library tests should be written as regular Go tests in the appropriate package.

The tool chain and runtime also have regular Go tests in their packages. The main reasons to add a new test to this directory are:

  • it is most naturally expressed using the test runner; or
  • it is also applicable to gccgo and other Go tool chains.