tinygo/compiler
Ayke van Laethem 0b7957d612 compiler: optimize string literals and globals
This commit optimizes string literals and globals by setting the
appropriate alignment and using a nil pointer in zero-length strings.

  - Setting the alignment for string values has a surprisingly large
    effect, up to around 2% in binary size. I suspect that LLVM will
    pick some default alignment for larger byte arrays if no alignment
    has been specified and forcing an alignment of 1 will pack all
    strings closer together.
  - Using nil for zero-length strings also has a positive effect, but
    I'm not sure why. Perhaps it makes some optimizations more trivial.
  - Always setting the alignment on globals improves code size slightly,
    probably for the same reasons setting the alignment of string
    literals improves code size. The effect is much smaller, however.

This commit might have an effect on performance, but if it does this
should be tested separately and such a large win in binary size should
definitely not be ignored for small embedded systems.
2021-04-08 11:40:59 +02:00
..
ircheck compiler: move IR checker to separate package 2020-03-21 15:45:25 +01:00
llvmutil compiler: move settings to a separate Config struct 2021-01-29 14:49:58 +01:00
testdata compiler: optimize string literals and globals 2021-04-08 11:40:59 +02:00
asserts.go compiler: do not emit nil checks for *ssa.Alloc instructions 2021-03-22 11:35:06 +01:00
atomic.go compiler: work around an ARM backend bug in LLVM 2021-02-03 14:49:41 +01:00
calls.go compiler: fix "fragment covers entire variable" bug 2021-03-29 10:16:59 +02:00
channel.go compiler: support all kinds of deferred builtins 2021-01-24 09:28:09 +01:00
compiler.go compiler: optimize string literals and globals 2021-04-08 11:40:59 +02:00
compiler_test.go compiler: add interface IR test 2021-03-28 14:00:37 +02:00
defer.go builder, compiler: compile and cache packages in parallel 2021-03-21 11:51:35 +01:00
errors.go compiler: remove ir package 2021-01-24 15:39:15 +01:00
func.go compiler: fix "fragment covers entire variable" bug 2021-03-29 10:16:59 +02:00
gc.go compiler: track the result of string concatenation 2020-04-02 14:04:25 +02:00
goroutine.go builder, compiler: compile and cache packages in parallel 2021-03-21 11:51:35 +01:00
inlineasm.go arm64: Add support for system calls (SVC) 2020-10-03 20:07:51 +02:00
interface.go transform: don't rely on struct name of runtime.typecodeID 2021-04-08 11:40:59 +02:00
interrupt.go builder, compiler: compile and cache packages in parallel 2021-03-21 11:51:35 +01:00
intrinsics.go compiler,runtime: translate memzero calls to LLVM memset intrinsics 2020-03-27 21:01:59 +01:00
llvm.go compiler: move settings to a separate Config struct 2021-01-29 14:49:58 +01:00
map.go compiler: refactor map operations to use the builder object 2020-03-25 20:17:46 +01:00
sizes.go reflect: implement Sizeof and Alignof for func values 2021-03-29 01:04:11 +02:00
symbol.go compiler: optimize string literals and globals 2021-04-08 11:40:59 +02:00
syscall.go compiler: move settings to a separate Config struct 2021-01-29 14:49:58 +01:00
volatile.go compiler: do not perform nil checking when indexing slices 2020-03-27 07:38:16 +01:00