tinygo/compiler/testdata
Ayke van Laethem c41a212712 wasm: avoid miscompile with ThinLTO
I found that when I enable ThinLTO, a miscompilation triggers that had
been hidden all the time previously. The bug appears to happen as
follows:

 1. TinyGo generates a function with a runtime.trackPointer call, but
    without an alloca (or the alloca gets optimized away).
 2. LLVM sees that no alloca needs to be kept alive across the
    runtime.trackPointer call, and therefore it adds the 'tail' flag.
    One of the effects of this flag is that it makes it undefined
    behavior to keep allocas alive across the call (which is still safe
    at that point).
 3. The GC lowering pass adds a stack slot alloca and converts
    runtime.trackPointer calls into alloca stores.

The last step triggers the bug: the compiler inserts an alloca where
there was none before but that's not valid as long as the 'tail' flag is
present.

This patch fixes the bug in a somewhat dirty way, by always creating a
dummy alloca so that LLVM won't do the optimization in step 2 (and
possibly other optimizations that rely on there being no alloca
instruction).
2023-01-18 08:24:42 +01:00
..
basic.go compiler: fix stack overflow when creating recursive pointer types 2022-12-22 17:45:05 +01:00
basic.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
channel.go compiler: avoid zero-sized alloca in channel operations 2021-09-09 11:24:52 +02:00
channel.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
defer-cortex-m-qemu.ll ci: add support for LLVM 15 2022-10-19 22:23:19 +02:00
defer.go compiler: insert basic blocks at an appropriate location 2022-06-16 07:59:21 +02:00
float.go compiler: test float to int conversions and fix upper-bound calculation 2021-01-19 14:02:32 +01:00
float.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
func.go compiler: add func tests 2021-04-12 12:07:42 +02:00
func.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
gc.go transform: remove switched func lowering 2022-01-19 14:42:02 -05:00
gc.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
generics.go compiler: implement unsafe.Alignof and unsafe.Sizeof for generic code 2022-07-28 15:43:51 +02:00
generics.ll compiler: implement unsafe.Alignof and unsafe.Sizeof for generic code 2022-07-28 15:43:51 +02:00
go1.20.go compiler: add support for new unsafe slice/string functions 2023-01-17 08:38:54 +01:00
go1.20.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
goroutine-cortex-m-qemu-tasks.ll ci: add support for LLVM 15 2022-10-19 22:23:19 +02:00
goroutine-wasm-asyncify.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
goroutine.go compiler: add support for the go keyword on interface methods 2021-10-31 14:17:25 +01:00
interface.go compiler: simplify interface lowering 2021-10-31 14:17:25 +01:00
interface.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
pointer.go compiler: refactor and add tests 2021-01-15 14:43:43 +01:00
pointer.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
pragma.go all: format code according to Go 1.19 rules 2022-08-04 12:18:32 +02:00
pragma.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
slice.go all: drop support for Go 1.16 and Go 1.17 2022-08-30 12:38:06 +02:00
slice.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00
string.go compiler: fix indices into strings and arrays 2021-11-13 11:04:24 +01:00
string.ll wasm: avoid miscompile with ThinLTO 2023-01-18 08:24:42 +01:00