tinygo/transform
Ayke van Laethem afd49e7cdd compiler: add support for recursive function types
This adds support for a construct like this:

    type foo func(fn foo)

Unfortunately, LLVM cannot create function pointers that look like this.
LLVM only supports named types for structs (not for pointers) and thus
can't add a pointer to a function type of the same type to a parameter
of that function type.

The fix is simple: cast all function pointers to a void function, in
LLVM IR:

    void ()*

Raw function pointers are cast to this type before storing, and cast
back to the regular function type before calling. This means that
function parameters will never refer to its own type because raw
function types are fixed at that one type.

Somehow, this does have an effect on binary size in some cases. The
effect is small and goes both ways. On top of that, there is work
underway in LLVM which would make all pointer types opaque (without a
pointee type). This would make this whole commit useless and therefore
should fix any size increases that might happen.
https://llvm.org/docs/OpaquePointers.html
2021-10-30 15:55:20 +02:00
..
testdata transform (coroutines): fix memory corruption for tail calls that reference stack allocations 2021-09-21 20:08:30 +02:00
allocs.go main: add -print-allocs flag that lets you print all heap allocations 2021-04-22 19:53:42 +02:00
allocs_test.go transform: split interface and reflect lowering 2021-05-03 20:10:49 +02:00
coroutines.go transform (coroutines): move any misplaced entry-block allocas to the start of the entry block before lowering 2021-09-21 20:08:30 +02:00
errors.go refactor coroutine lowering and tasks 2020-03-17 12:16:10 +01:00
func-lowering.go compiler: decouple func lowering from interface type codes 2021-04-12 12:07:42 +02:00
func-lowering_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
gc.go transform: improve GC stack slot pass to work around a bug 2021-08-04 20:06:59 +02:00
gc_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
globals.go compiler: add function and global section pragmas 2021-06-24 15:00:30 +02:00
globals_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
goroutine_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
interface-lowering.go transform: work around renamed return type after merging LLVM modules 2021-10-28 09:20:08 +02:00
interface-lowering_test.go transform: split interface and reflect lowering 2021-05-03 20:10:49 +02:00
interrupt.go compiler: add support for recursive function types 2021-10-30 15:55:20 +02:00
interrupt_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
llvm.go runtime/fe310: add support for PLIC interrupts 2020-01-27 19:58:39 +01:00
maps.go all: move OptimizeMaps to transforms and add tests 2019-09-15 21:26:27 +02:00
maps_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
optimizer.go transform: split interface and reflect lowering 2021-05-03 20:10:49 +02:00
panic.go compiler: move ReplacePanicsWithTrap pass to transforms 2019-11-16 18:41:28 +01:00
panic_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
reflect.go transform: split interface and reflect lowering 2021-05-03 20:10:49 +02:00
reflect_test.go transform: split interface and reflect lowering 2021-05-03 20:10:49 +02:00
rtcalls.go compiler: refactor method names 2021-06-17 12:17:32 +02:00
rtcalls_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
stacksize.go arm: automatically determine stack sizes 2020-08-27 19:23:22 +02:00
stacksize_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00
transform.go all: refactor heap-to-stack transform into the transform package 2019-09-15 21:26:27 +02:00
transform_test.go main: test other architectures by specifying a different GOARCH 2021-10-04 18:22:55 +02:00
util.go compiler: move OptimizeStringToBytes to transform package 2019-09-22 08:25:50 +02:00
wasm-abi.go builder: add optsize attribute while building the package 2021-04-08 11:40:59 +02:00
wasm-abi_test.go transform: move tests to transform_test package 2021-04-22 19:53:42 +02:00