Skip to content

GC stack slots by liveness - #1

Merged
alixander merged 10 commits into
d2from
gc-slot-liveness
Nov 26, 2026
Merged

alixander merged 10 commits into
d2from
gc-slot-liveness

Conversation

@alixander

@alixander alixander commented Nov 25, 2026 •

Copy link
Copy Markdown

Gives a pointer a slot in its function's stack object only while a collection can find it in use, instead of giving every tracked pointer a slot for the whole function. With it, D2's WebAssembly module is 10,558,431 bytes, 3,570,072 after brotli, against 11,159,250 and 3,728,122 with v0.44.0-d2.2 (−5.4% / −4.2%). It has 85,600 slots.

The rule (stated in full in the comments of gcSlotFunc, findCarriers, passesThrough and selfDerived in transform/gc.go)

  • A value needs a slot if it is in use when a call that can reach the collector is made or returns. That means passed to the call as a pointer (callees do not root their parameters), or used after it, round a loop included.
  • An integer that may hold a pointer counts like a pointer, whatever its use after the call: a comparison would find a new object at the address of a freed one.
    • LLVM copies small objects (one or two pointers, a string, an interface) as integers. So the integers that loads and atomic operations produce count, unless the compiler marked the load as one of a Go value made of integers, floats and booleans (llvmutil.NoPointerMDName, put by loadFromStorage; never a uintptr).
    • Integers that calls return do not count: function result types are those of the Go source.
    • Whatever an address is computed from counts, whatever its type.
  • What a value in use is made of is followed back, through any calculation, to where its bits came in (a load, a call), and that value gets the slot.
    • The search goes on past a value with a slot of its own that is not a load or a call (a conversion to a pointer, a phi, a select). Its slot holds what goes into it unchanged, and what an address is computed from on the way needs a slot of its own.
    • A phi in a loop that steps through an object needs what it starts from, also when a load or a call made it.
  • New allocations without a slot, and stack variables that may hold a pointer during a collection, are passed to tinygo_exposeStackObject. Link-time optimization then cannot carry them across a call in a register. Functions that expose their stack lose their tail marks.
  • A function the analysis cannot follow keeps every value that may bring a pointer in.

What is assumed (written down in findCarriers and selfDerived):

  • A pointer that a callee or memory moves stays inside its object or at the end of its data, as the rules of package unsafe require. TinyGo's original pass kept every allocation in a slot for the whole function, so code that breaks those rules could get away with it there.
  • Go code does not take pointers apart into pieces narrower than a word, or convert them to floats.
  • Outside unsafe code, no memory is read both as a Go integer and as a pointer.

Review. Four adversarial rounds, each with several independent attackers and a skeptic or two for every finding.

  • Rounds 1 and 2 found use-after-free in safe Go: a pointer carried as an integer, and an integer only compared after a collection. They led to the rule above.
  • Rounds 3 and 4 found nothing that valid Go reaches. What they found in hand-written IR, cgo C code and code that breaks the unsafe rules is fixed or written down.

Tests

  • transform/testdata/gc-slotliveness.ll covers:
    • integers compared, calculated with and stored after a collection;
    • marked loads, with and without an address computed from them;
    • integer arguments of collecting calls;
    • pointers that step past the end of their objects, from allocations, loads and strings;
    • tracked values, floats, vectors and intrinsics.
  • testdata/gc-identity.go, run under gc.stress by runGCRootsTest, compares pointers copied with copy() against new objects after collections. The previous rule fails it in the first round.
  • TinyGo's WebAssembly suite passes, except gc.go-boehm, which needs lib/bdwgc (not checked out here).
  • With transform.GCSlotCheck set, the pass checks itself: it walks back from every use and reports any value that crosses a collection without a slot. It reports none on D2's module. On the same module it reports 12,421 values when the pass ignores integers, and 300 when it ignores pointers that step.

D2 (d2lang/d2#3046 at f6d72373a):

  • Its behaviour harness gives the same 24,824 results as master's module.
  • Under -tags=gc.stress (a collection at every 67th allocation), its 993 requests give the same results and read no freed memory.

🤖 Generated with Claude Code

alixander and others added 4 commits November 25, 2026 05:24
The block collector only runs when the heap is full. A pointer that the
compiler failed to root usually does no harm: the object is still there
when the program uses it, because no collection came in between. Such a
bug shows up in production, once, and never in a test.

With -tags=gc.stress the collector is built for finding it:

- Every allocation first runs a full collection.
- The blocks that a collection frees are filled with 0xDEADBEE1. A
  program that still uses the object traps when it loads a pointer from
  it (on WebAssembly that address is out of bounds) or prints something
  else than it should.
- Allocations are taken from the longest free range, so freed blocks keep
  the pattern as long as possible instead of being handed out again.
- The collector stops the program if it finds the pattern where it looks
  for pointers.
- On WebAssembly the unused part of the stack is cleared before the stack
  is scanned. The scan is conservative, and a pointer left behind by a
  call that has returned could otherwise root an object by accident.

A program that allocates too much for a collection per allocation can
call the exported tinygo_gcStressSetPeriod(n) to collect at every nth
allocation.

Without the tag nothing changes: gcStress is a constant false and the
programs in testdata build to the same bytes as before (checked with
-no-debug on gc.go, map.go, json.go, stdlib.go and channel.go).

What it finds, on the wasm target with testdata/*.go: with the stack slot
pass as it is, every program passes with -scheduler=none
-panic-unwind=explicit (35 programs) and all but one with the default
scheduler (45 programs). The exception is finalizeridle.go, which tests
that a collection runs after enough finalizers were registered since the
last one, and here there is always a last one. With a compiler changed to
store no pointer in a stack slot at all, 25 of the 35 fail (2 without the
tag). With every tenth slot left out, 4 of the 35 and 15 of the 45 fail.

D2 allocates too much for a collection at every allocation. With one at
every 67th allocation, 17 short scripts sent through every layout engine
and renderer gave 992 of 993 results as without the tag. In the remaining
one the collector found the pattern among the roots, and it is a pointer
that the compiler does not root. A function of the TALA layout ranges
over a slice that it read from a map, and the loop body replaces that map
entry. The compiler does not track the result of a map lookup: the slice
is in the lookup buffer on the stack, until the next lookup in the loop
reuses the buffer, and from then on in a local variable only. The next
collection frees the array under the loop, which goes on reading it. The
request fails in some runs and not in others, since map iteration order
differs between runs and with it where the collections fall; with a
collection at every 23rd allocation it failed in 3 runs of 5. The next
commit roots the pointer.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…it in use

On WebAssembly every pointer that a function creates was stored in a slot
of the function's stack object, because the collector cannot see local
variables. Most of those pointers are done with before anything can
collect: the intermediate loads of a.b.c.d, results that are passed on at
once. In D2 that was 218,927 slots in 9,421 stack objects.

The rule

The collector can only run inside a call that reaches it: a call of
runtime.alloc, of a function without a body that may touch memory, a call
through a function pointer, inline assembly, or a call of a function that
makes one of those. A pointer now gets a slot only if it is in use when
such a call is made or when it returns:

- as an argument of the call, since a callee does not root its parameters;
- or anywhere the call can lead to, round a loop included.

"In use" means the pointer or anything computed from it without going
through memory or a call: interior pointers, casts, phis, selects, fields
put into an aggregate and taken out again, the integer after ptrtoint and
whatever is computed from that. A field of an aggregate that is taken out
without a pointer in it (the length of a string) is not a use. The search
stops at a value that has a slot decision of its own.

The values that are looked at are not just the tracked ones. Every load,
call, inttoptr and every phi in a loop that produces a pointer is, tracked
or not: that is every way a pointer into the heap gets into a function. The
compiler does not track the pointer it reads from a map lookup buffer, or
the argument of a deferred call that it loads from the defer record. So far
such a pointer was only safe as long as the map or the record still held
it. D2 has a loop where nothing does: it ranges over a slice read from
a map and replaces the map entry in the loop body, and with the pass as
it was a collection in that loop frees the slice (found with gc.stress,
see the previous commit). The slice pointer now has a slot.

A pointer is rooted where it is made. The compiler tracks the pointer of
a string that a call returns only after it has repacked the result and
tested for a panic. The slot now takes the field of the call's own result,
right behind the call.

What keeps this true after the pass

The pass runs before link time optimization. Stores into a stack object
and calls keep their order, so what has a slot is in its slot when the
call is made. What must not happen is that LLVM carries a pointer without
a slot across a collecting call. It can move a load or a store past a call,
or keep in a value what was in memory during the call, only for memory
that as far as it knows the call cannot touch: a new object that has not
escaped, or a stack variable that has not. So:

- A new allocation (the result of a call with a noalias result) that gets
  no slot is passed to tinygo_exposeStackObject, the empty function that
  stack objects are passed to. For LLVM it has then escaped like every
  allocation did through its slot. Without this LLVM reads a copy from the
  object after the call instead of from the stack copy made before it.
- A stack variable that may hold a pointer made in this function while a
  collection runs is passed to it as well: one that such a pointer may be
  written to (by a store, a copy, or a function that is given the address),
  with a collecting call after the write and before or at a later use. It
  stays in memory and holds the pointer during the call; the stack is
  scanned. Without this, a pointer that a function stores through a
  parameter ends up in a local variable of its caller once LLVM has inlined
  the function. This case was not covered before either: the slot of the
  inlined function is dead when the function is over.
- Globals with pointers have their address in the table of global roots.
  Without that table (other collectors) every tracked pointer keeps its
  slot, as before.
- A function that exposes part of its stack has no call marked 'tail'
  left: LLVM takes such a call to leave the caller's stack alone.
- A function with something the analysis does not know (a call that can
  return twice, an invoke, a vector of pointers) keeps all its slots.

Slots are still cleared on entry, now only the ones that are left.

Numbers for D2

As the pass gets the module: 99,980 slots in 6,838 stack objects instead
of 218,927 in 9,421; 19,252 stack variables and 7,244 allocations are
exposed. As the linker hands it to wasm-opt: 102,295 stores into 98,022
slots instead of 198,907 into 213,644, and 392,088 bytes cleared on entry
instead of 854,576.

The module is 15,538,078 bytes instead of 16,295,440 (-757,362, 4.6%),
and 4,666,372 instead of 4,865,161 after brotli (-198,789, 4.1%). 6,611
functions got smaller by 863,634 bytes together; 655 got bigger by
109,876, mostly because a stack variable now stays in memory.

The 24,817 requests of the behaviour harness give the same results as
before. Under the stress collector (gc.stress, a collection at every 67th
allocation) so do the 993 requests of 17 short scripts sent through every
layout engine and renderer, the one that failed before included, and with
a collection at every allocation the 48 requests of one script.

Two checks were run on the module of D2 and on those of 40 test programs
while developing: the liveness query agrees with a textbook data flow
computation for all 822,075 values that can carry a pointer, and walking
back from each of the 199,510 that are in use at a collecting call ends at
a slot, a parameter, a constant or a stack address.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
transform/testdata/gc-slotliveness.ll has a function for each way the
pass can go wrong, with a pointer that must keep its slot next to one that
may lose it:

- use after a collecting call, use as an argument of one, a call through a
  function pointer, runtime.KeepAlive, a call that cannot collect;
- derived values: an interior pointer, the pointer as an integer and back,
  fields of a string (length only, the same field taken out twice, the
  result of a call repacked by the compiler), a pointer in an aggregate
  argument, a phi and a select of two pointers;
- loops: a value carried round, a phi the compiler did not track, a loop
  in which nothing is in use at a call;
- a loaded pointer that was not tracked;
- the check for a panic after a call, with a deferred use on the other
  branch; a call in tail position; a call that returns twice;
- memory: a new object without a slot, a pointer kept in a stack variable
  across a call, a stack variable filled by a callee or by a copy, and
  stack variables that are left alone: one that only holds a parameter,
  one that holds a pointer only while nothing collects, one without
  pointers.

testdata/gc-roots.go is the same at the other end: 24 small functions that
each keep an object alive through one kind of local value while a
collection runs (an interior pointer, a slice that walks to its end, a
map lookup after the entry is deleted, a closure, the argument of a
deferred call, a recovered panic value, a stack array, a variable filled
by a callee, ...) and then read it. TestBuild runs it on wasm as it is and,
with gc-liveness-repro.go and gc.go, with -tags=gc.stress, with the
default scheduler and with -scheduler=none -panic-unwind=explicit.

The last function is the loop from D2 that the stack slot pass did not
root before: a range over a slice read from a map, with the map entry
replaced in the loop body. With the pass as it was the program crashes
there, with either scheduler: with a memory access out of bounds, and
under the stress collector with a nil pointer panic. The other 23 pass
with the pass as it was.

With a compiler that stores nothing in stack slots, 10 of the first 16
functions fail without the stress collector before the program traps, and
with it the first five.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…nteger

The liveness rule looked at values with a pointer in their type and at the
integers that a ptrtoint makes. LLVM makes integers of pointers on its own,
before this pass runs: InstCombine turns a memmove of 4 or 8 bytes (copy()
of one or two pointers, of a string, of an interface) into a load and
a store of an i32 or i64, SROA removes the variable that was copied to, and
what is left is

    %both = load i64, ptr %from
    call void @collects()
    %low = trunc i64 %both to i32
    %p = inttoptr i32 %low to ptr

During the call the two pointers are in a wasm local and nowhere else once
the memory they were read from is cleared. The integer had no slot, and
the inttoptr got its slot too late: a use after free in safe Go. Before
the liveness rule the objects mostly survived because every tracked
pointer kept its slot for the whole function; pointers that were not made
in the function (read from a slice of the caller, from a global) were
lost then as well.

The rule, corrected

A pointer gets a slot if it is in use when a collecting call is made or
when it returns. That is unchanged, but a pointer does not need to have
the type of one:

- An integer of at least the size of a pointer that comes out of memory
  or out of a call (a load, a call result, atomicrmw, cmpxchg, va_arg,
  or such a field of an aggregate that one of these produces) may be
  a pointer, and so may what is made of it by the instructions that keep
  its bits together: trunc, zext, sext, the shifts, and, or, bitcast,
  freeze, phi, select, insertvalue, extractvalue, a rotation.
- Whatever an inttoptr is computed from is one, through any arithmetic,
  and so is what a getelementptr on null is computed from.
- Such an integer gets a slot if it is in use across a collecting call
  and that use delivers its bits to where a pointer can be used or found
  again: an inttoptr (or that getelementptr), the value of a store or of
  an atomic operation, an argument of a call, a return. The slot takes
  the integer as it is, i32 or i64: the collector reads the stack word by
  word. It is filled where the integer is made, and an integer that a phi
  carries round a loop has a slot for the phi, as a pointer has.
- An integer that is only compared or calculated with (a length, an
  index, a sum) is a pointer for nobody and gets nothing.
- Being passed to the collecting call itself is not a use across it:
  a function takes the integers it is given for integers, and does not
  root its parameters. The types of parameters and results are those of
  the Go source, LLVM does not make integers of them; what it does to
  memory it can only do inside a function, and that is what is covered.
- A function that keeps all its slots because the pass cannot follow it
  (a call that returns twice, an invoke, vectors) keeps every such
  integer that is delivered anywhere.
- A stack variable that such an integer is stored to holds a pointer for
  the rule that exposes stack variables (mayBePointer), also when it is
  not the load itself that is stored but a part of it.

A pointer-sized integer made from a pointer by ptrtoint and carried round
a loop by a phi gets a slot for the phi now too.

The pass can check this itself: with transform.GCSlotCheck set it walks
back from every inttoptr and from every integer that is stored, passed or
returned to where the bits come from, and reports what crosses
a collecting call on that way without a slot. The tests of the package
run with it, and it reports nothing for the module of D2 (and 4,659 uses
when every third of these slots is left out to try it).

Tests: gc-slotliveness.ll has the two forms from above, the half that is
taken before the call, the address without inttoptr, arithmetic on the
way, the loop, the stack variable, and the integers that must not get
a slot. testdata/gc-intcopy.go is the program: copies of two pointers, of
a string and of an interface, of pointers that come from the caller, the
integer that is stored and never converted, and the loop. The first four
are the programs that failed in review. With gc.stress the compiler before
the liveness rule fails in two (fromSlice, storedLater), at -opt=2 and z.

Numbers for D2, as the pass gets the module: 124,449 slots in 6,969
stack objects instead of 99,980 in 6,838. 24,475 slots hold an integer
(101,040 bytes of stack objects), of which about 9,600 are integers by
themselves and the rest lengths and other integer fields of aggregates
that a call or a load produced. 495 more stack variables are exposed.
The pass takes as long as before (2.1 s).
The module is 15,739,138 bytes instead of 15,538,078 (+201,060), and
4,734,814 instead of 4,666,372 after brotli (+68,442); with every tracked
pointer in a slot, as before the liveness rule, it was 16,295,440 and
4,865,161. The 24,817 requests of the behaviour harness give the same
results as before, and so do the 993 requests of the stress run (gc.stress,
a collection at every 67th allocation).

What the parts of the rule cost, measured the same way: only loads as the
source and only inttoptr and stores as the use, 7,322 slots; with calls as
a source 13,062; with arguments and returns as a use instead 12,445; both,
as it is now, 24,608. Counting an integer argument of the collecting call
itself as in use, like a pointer, would be 53,744. (These five were counted
while a getelementptr on a global was still taken for an address made of
integers, which is the 133 slots between 24,608 and 24,475.) Linked from
the module the pass produces, D2 with the first of these (7,189 slots
now) is 136,628 bytes smaller than with the rule as it is, 51,057 after
brotli: about two thirds of what this change costs go to the integers
that calls return and to those that are passed on or returned.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

Copy link
Copy Markdown

Size difference with the dev branch:

Binary size difference
 flash                          ram
 before   after   diff          before   after   diff
  68788   68772    -16  -0.02%    9484    9484      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
  65192   65176    -16  -0.02%    6368    6368      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
  17880   17880      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650
  63120   63120      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
  10624   10624      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
  17200   17200      0   0.00%    7240    7240      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
   9840    9840      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
  13216   13216      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
  12060   12060      0   0.00%    5148    5148      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
   8856    8856      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
   9328    9328      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
   8624    8624      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  72256   72256      0   0.00%    3720    3720      0   0.00% tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
  67664   67664      0   0.00%    6592    6592      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  20512   20512      0   0.00%    5200    5200      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/bmi270/i2c/main.go
  22504   22504      0   0.00%   16696   16696      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/bmi270/spi/main.go
  16028   16028      0   0.00%   17208   17208      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/bmm150/main.go
  28400   28400      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  66416   66416      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  13024   13024      0   0.00%    5208    5208      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
  22184   22184      0   0.00%    5864    5864      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-rp2350 ./examples/bno08x/i2c/main.go
   9256    9256      0   0.00%    3360    3360      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
  23092   23092      0   0.00%    3592    3592      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  30796   30796      0   0.00%    5408    5408      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/alarms/main.go
  44652   44652      0   0.00%    5408    5408      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/basic/main.go
   4776    4776      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
   6992    6992      0   0.00%    2344    2344      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/async/main.go
  72932   72932      0   0.00%    7444    7444      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
   7508    7508      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
  23676   23676      0   0.00%    8588    8588      0   0.00% tinygo build -size short -o ./build/test.bin -target=esp32-coreboard-v2 ./examples/gdew0154m09/main.go
  69244   69244      0   0.00%    6832    6832      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
  69712   69712      0   0.00%    6932    6932      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
   9368    9368      0   0.00%    5192    5192      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
   5896    5896      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5976    5976      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
   6753    6753      0   0.00%     585     585      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/hd44780/keypadshield/main.go
  11376   11376      0   0.00%    5160    5160      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  16096   16096      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  16548   16548      0   0.00%    2428    2428      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  11120   11120      0   0.00%    7368    7368      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  13488   13488      0   0.00%    5328    5328      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  12876   12876      0   0.00%    6012    6012      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ili9341/pico
  11612   11612      0   0.00%    6004    6004      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico2-w ./examples/ili9341/pico
  30456   30456      0   0.00%   38528   38528      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  11080   11080      0   0.00%    7368    7368      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  13512   13512      0   0.00%    5328    5328      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
 265536  265536      0   0.00%   47212   47212      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
  12624   12624      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-zero ./examples/ili9325/itdb02
  12693   12693      0   0.00%    1022    1022      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/ili9325/itdb02
  23056   23056      0   0.00%   17384   17384      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-zero ./examples/ili9325/lorenz
  11696   11696      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
  15488   15488      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
  26616   26616      0   0.00%    2328    2328      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  29200   29200      0   0.00%    7224    7224      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/lsm303dlhc/main.go
  13312   13312      0   0.00%    5184    5184      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
  11904   11904      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
  10776   10776      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
  11176   11176      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
  11040   11040      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
  74056   74056      0   0.00%    6696    6696      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
  30744   30744      0   0.00%    4152    4152      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  30632   30632      0   0.00%    6196    6196      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
   9360    9360      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
   9312    9312      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  79280   79280      0   0.00%    7856    7856      0   0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  71192   71192      0   0.00%    7416    7416      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=waveshare-rp2040-pizero ./examples/dothat-pizero/
  13324   13324      0   0.00%    5804    5804      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
   6692    6692      0   0.00%    3292    3292      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   5092    5092      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
  14368   14368      0   0.00%   16856   16856      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/motion/main.go
  13976   13976      0   0.00%   19328   19328      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/frame/main.go
  13340   13340      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw/soil-sensor
  12972   12972      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=qtpy-rp2040 ./examples/seesaw/rotary-encoder
   2899    2899      0   0.00%     560     560      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
  14916   14916      0   0.00%    5868    5868      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico     ./examples/sgp30
   8864    8864      0   0.00%    7176    7176      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
  59008   59008      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  58944   58944      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  59008   59008      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
  14344   14344      0   0.00%    8872    8872      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-ble ./examples/ssd1306/
  12860   12860      0   0.00%    5836    5836      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-rp2040 ./examples/ssd1306/
  12796   12796      0   0.00%    5828    5828      0   0.00% tinygo build -size short -o ./build/test.hex -target=thumby ./examples/ssd1306/
   6356    6356      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   7140    7140      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
   6820    6820      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  19000   19000      0   0.00%    6368    6368      0   0.00% tinygo build -size short -o ./build/test.hex -target=waveshare-rp2040-pizero ./examples/st7789/waveshare-1in3-lcd-hat/
  18016   18016      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
  12032   12032      0   0.00%    4960    4960      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
  11392   11392      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  11776   11776      0   0.00%    5800    5800      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive
  10216   10216      0   0.00%    7168    7168      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
  13332   13332      0   0.00%    7428    7428      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
  16664   16664      0   0.00%    5240    5240      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
  29720   29720      0   0.00%   17208   17208      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/vl53l3cx/main.go
  15160   15160      0   0.00%    5240    5240      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
  26588   26588      0   0.00%   14148   14148      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go
   6804    6804      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   6484    6484      0   0.00%    2316    2316      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
  20532   20532      0   0.00%    6900    6900      0   0.00% tinygo build -size short -o ./build/test.hex -target=waveshare-rp2040-pizero ./examples/waveshare-epd/epd2in7gray/main.go
  77016   77016      0   0.00%    6168    6168      0   0.00% tinygo build -size short -o ./build/test.hex -target=waveshare-rp2040-pizero ./examples/waveshare-epd/epd2in7gray-slideshow
   6676    6676      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
  29068   29068      0   0.00%   18868   18868      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go
   7936    7936      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
   6168    6168      0   0.00%    8464    8464      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-c3          ./examples/ws2812
   1911    1911      0   0.00%     600     600      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
   1296    1296      0   0.00%     182     182      0   0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
   6560    6560      0   0.00%    8728    8728      0   0.00% tinygo build -size short -o ./build/test.bin -target=xiao-esp32c3 ./examples/ws2812
   8484    8484      0   0.00%    3020    3020      0   0.00% tinygo build -size short -o ./build/test.hex -target=teensy36 ./examples/ws2812
   3821    3821      0   0.00%     582     582      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino      ./examples/ws2812/neopixel-shield
   7984    7984      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-zero ./examples/ws2812/neopixel-shield
  32768   32768      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  17544   17544      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go
  12272   12272      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go
  13248   13248      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go
   7680    7680      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go
   9616    9616      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go
   7648    7648      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go
  10032   10032      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go
   8180    8180      0   0.00%    3324    3324      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go
   7596    7596      0   0.00%    2288    2288      0   0.00% tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go
  14480   14480      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go
  12176   12176      0   0.00%    5152    5152      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go
  79536   79536      0   0.00%    6768    6768      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go
   8323    8323      0   0.00%     812     812      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/keypad4x4/main.go
  38316   38316      0   0.00%    6372    6372      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/
  72720   72720      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/
   8304    8304      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/
  67376   67376      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/
  72560   72560      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/
  13500   13500      0   0.00%    5796    5796      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go
  12092   12092      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/
   9808    9808      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go
  14000   14000      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go
  11392   11392      0   0.00%    5192    5192      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina3221/main.go
  10600   10600      0   0.00%    5280    5280      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go
  74104   74104      0   0.00%   11368   11368      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/
  62720   62720      0   0.00%    8632    8632      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/
  11072   11072      0   0.00%    7184    7184      0   0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/
   9896    9896      0   0.00%    5728    5728      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go
  12504   12504      0   0.00%    4692    4692      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/basic/
  20068   20068      0   0.00%    4964    4964      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/touchpaint/
  14400   14400      0   0.00%    5060    5060      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/
  46476   46476      0   0.00%    9344    9344      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/sx127x/lora_rxtx/
  35456   35456      0   0.00%    7496    7496      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go
  12572   12572      0   0.00%    6780    6780      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go
  13780   13780      0   0.00%    5852    5852      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/sender/main.go
  13428   13428      0   0.00%    5804    5804      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go
  13156   13156      0   0.00%    6248    6248      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/waveshare-epd/epd2in9v2/main.go
  15040   15040      0   0.00%    5840    5840      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd30/main.go
  11804   11804      0   0.00%    5816    5816      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go
   8856    8856      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go
  10528   10528      0   0.00%    5152    5152      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go
 124764  124764      0   0.00%    8472    8472      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/
  17600   17600      0   0.00%    7408    7408      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go
  12812   12812      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go
   8736    8736      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go
  69372   69372      0   0.00%    7276    7276      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go
  63608   63608      0   0.00%    3792    3792      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go
  67376   67376      0   0.00%    6656    6656      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go
  10492   10492      0   0.00%    5780    5780      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go
  12584   12584      0   0.00%    5856    5856      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi
  12192   12192      0   0.00%   16648   16648      0   0.00% tinygo build -size short -o ./build/test.bin -target=esp32s3-generic ./examples/st7567/
   9444    9444      0   0.00%    6220    6220      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt
  67772   67772      0   0.00%    7236    7236      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go
  45236   45236      0   0.00%    7876    7876      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
  13160   13160      0   0.00%    5736    5736      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
  13892   13892      0   0.00%    4956    4956      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
  64156   64156      0   0.00%    6404    6404      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
  13964   13964      0   0.00%    5796    5796      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ens160/main.go
  17444   17444      0   0.00%    5900    5900      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/si5351/main.go
  22916   22916      0   0.00%    7156    7156      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/w5500/main.go
  90736   90736      0   0.00%    7604    7604      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sd
  89408   89408      0   0.00%    7672    7672      0   0.00% tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/
 375068  375068      0   0.00%   14344   14344      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal -stack-size 8kb ./examples/net/http-get/
 125688  125688      0   0.00%    8812    8812      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 -stack-size 8kb ./examples/net/tcpclient/
 353408  353408      0   0.00%   12840   12840      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/websocket/dial/
 107948  107948      0   0.00%   10792   10792      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-m4-airlift -stack-size 8kb ./examples/net/socket/
 422280  422280      0   0.00%   17176   17176      0   0.00% tinygo build -size short -o ./build/test.hex -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic/
 170380  170380      0   0.00%   10924   10924      0   0.00% tinygo build -size short -o ./build/test.hex -tags=noslog -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic-httphi/
 147900  147900      0   0.00%    8900    8900      0   0.00% tinygo build -size short -o ./build/test.hex -tags=noslog -target=arduino-nano33 -stack-size 4kb ./examples/net/webserver-httphi/
 170452  170452      0   0.00%    8880    8880      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-mkrwifi1010 -stack-size 8kb ./examples/net/tlsclient/
 161592  161592      0   0.00%    9584    9584      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/mqttclient/natiu/
 124632  124632      0   0.00%   14104   14104      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/
 372776  372776      0   0.00%   19644   19644      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/
 143476  143476      0   0.00%   14204   14204      0   0.00% tinygo build -size short -o ./build/test.hex -tags=noslog -target=wioterminal -stack-size 8kb ./examples/net/webserver-httphi/
 371744  371744      0   0.00%   18496   18496      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/
 177564  177564      0   0.00%   11992   11992      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2040 -stack-size 8kb ./examples/net/tlsclient/
 124968  124968      0   0.00%   11880   11880      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2350 -stack-size 8kb ./examples/net/ntpclient/
   6932    6932      0   0.00%    4340    4340      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-uno-r4-wifi ./examples/unor4matrix/checkerboard/
  12428   12428      0   0.00%    4404    4404      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-uno-r4-wifi ./examples/unor4matrix/life/
 118244  118244      0   0.00%    8236    8236      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-uno-r4-wifi -stack-size 4kb ./examples/net/tcpclient/
 118780  118780      0   0.00%    8268    8268      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-uno-r4-wifi -stack-size 4kb ./examples/net/ntpclient/
8062108 8062076    -32  -0.00% 1329267 1329267      0   0.00%

alixander and others added 6 commits November 26, 2026 02:39
d2.2 roots map lookups and globals that LLVM retyped to an integer, and
stores the table of global roots as runs. Conflicts: an import in
transform/gc.go, and the lists of programs that runGCRootsTest builds
with gc.stress, which now has the programs of both branches.

gc-slotliveness.out.ll: d2.2 roots every integer global of one or two
pointer words, so the test's @unwinding (an i32 in memory there) is now
in the table of global roots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rule of the previous commit gave an integer that may hold a pointer
a slot only if a use after the collection delivered its bits: made an
address of them, stored them, passed them on or returned them. The second
review found what that misses. An integer that is only compared after
a collection loses its object, and a new object at the same address
compares equal: two different live pointers are ==, in safe Go. And
arithmetic on such an integer on its way to a store was covered only by
accident. Any use can observe the address, so such an integer is now
treated like a pointer:

- It is in use across a collection if anything computed from it is used
  after the call, whatever the use. Its bits are followed through every
  instruction that computes a value (all operands except the condition of
  a select and the distance of a shift) back to where they entered the
  function, and that value gets the slot.
- The integers that may hold a pointer are those that loads and atomic
  operations produce, of at least the size of a pointer. Not those that
  calls return: function result types are those of the Go source, which
  LLVM does not change at the levels TinyGo optimizes at. Not those of
  loads that MarkNoPointerLoads marked: it marks every load of an integer,
  a float or an aggregate of those at the start of Optimize, before LLVM
  makes loads of its own, so a marked load reads a Go value without
  pointers. LLVM drops metadata it does not know when it changes or
  merges a load, and keeps it on a duplicate of the same load. What an
  address is computed from counts whatever its type, a double included.
- An integer passed to the collecting call itself is still not in use
  across it: the callee takes it as an integer.
- A conversion to a pointer and a phi in a loop keep their own slots,
  and the search goes on past them. A value that goes into them unchanged
  (through a phi, a select, a cast, a field) is held by their slot, but
  what an address is computed from on the way is needed itself. A pointer
  that runs one element ahead points past the end of its object in the
  last round, where the slot of the phi does not keep the object; the
  pointer it was computed from now has a slot.
- A function the analysis cannot follow keeps every value that may bring
  in a pointer, not only the integers that are delivered.

The self-check now walks back from every use that consumes a value
(anything but an instruction that passes the bits on) instead of from
the deliveries, with the same exceptions for slots that hold what goes
into them. With integer carriers ignored by the pass it reports every
integer case of gc-slotliveness.ll.

Tests: gc-slotliveness.ll gets the comparison, arithmetic before
a store, a marked load with and without an address made from it, an
integer argument of the collecting call, a double that becomes an
address, the pointer that runs ahead, and a list walk where the phi
alone holds the node. testdata/gc-identity.go is the second review's
program: copies of a pointer, of a pair and of an interface compared
with new objects after collections. With gc.stress the previous rule
fails it at the first round (copiedPointer 0, copiedPair 0); this one
passes. runGCRootsTest runs it.

D2's WebAssembly module is 10,652,158 bytes, 3,580,658 after brotli;
with the previous rule 10,698,214 and 3,598,118, with TinyGo's original
pass (v0.44.0-d2.2) 11,260,082 and 3,732,338. Its 24,755 requests of the
behaviour harness give the same results as with d2.2, and so do the 993
requests of the stress run (gc.stress, a collection at every 67th
allocation).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…argument

A pointer passed to a collecting call needs a slot during the call, as
the callee does not root its parameters. So do the pointers in an
aggregate that is passed by value. Its integers do not: the callee takes
them for the integers its Go type says they are, which is what the pass
does as well. The check asked for every field and reported 324 values in
D2's module, all of them structs passed by value; it now reports none.

On D2's module it is not vacuous: with the integers that may hold
a pointer ignored by the pass it reports 12,421 values, and with the
addresses computed on the way into a loop phi taken as unchanged 300.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pointers past the end of an object. A phi in a loop that steps through an
object (computed from its own value with an address computed on the way)
can point past the end of the object it started in, where its slot no
longer keeps that object. The values it starts from now get slots of
their own, also when a load or a call made them; before, only a start
value computed from a pointer with a slot was covered. The same goes for
an address stepped as an integer. And the search for what a value in use
is made of now goes on past every value with a slot that is not a load
or a call (a tracked phi or select outside a loop too), as it did only
past conversions to pointers and phis in loops. Valid Go goes at most to
the end of an object's data, where the object's header still lies, but
code that breaks the rules of unsafe could free an object this way.

The marks of loads without pointers. The compiler now marks the loads of
Go values it makes itself (loadFromStorage: dereferences, elements,
fields, received values) when the Go type is made of integers, floats and
booleans, and never a uintptr, which can hold an address. The pass that
marked every load of an integer at the start of Optimize is gone: it also
marked the integer copies clang makes of pointers in C code, and the
uintptr fields of string and slice headers, whose marks only an inttoptr
next to them overrode.

Pointer bits through floats. Floating-point arithmetic and conversions
pass bits on: a pointer of 32 bits fits a double exactly, so an address
computed after a round trip comes from the load before it. A field of an
aggregate that is a float or a vector with room for a pointer is kept like
an integer field. A vector of pointers counts as having pointers, so the
fallback for functions the pass cannot follow keeps one that a call
returns.

The self-check states what it shares with the pass: the model of which
values may hold a pointer and which a slot holds unchanged.

Tests in gc-slotliveness.ll: a pointer that steps from an allocation past
its end, an integer address stepped from a load, a tracked select that
holds the end of an object, an address made of the double field of
a loaded struct, a round trip through a double, and a vector of pointers
that a call returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit gives the values a stepping phi in a loop starts from
slots of their own. For an aggregate, a string say, the slot is that of
its pointer field, and the code that decides about fields skipped every
user with a slot of its own, the stepping phi included. So the string
a call returned and a loop then sliced (s = s[1:]) had no slot. The
self-check found 81 such values in D2's module (time.parse,
path.matchChunk); it finds none now. A needed phi in a loop that steps
through an object counts as a user that needs the field.

Test: stringSliced in gc-slotliveness.ll.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fourth review found no value that valid Go leaves without a slot. It
found these, all in hand-written IR or in code that breaks the rules of
package unsafe:

- A tracked value that changes the pointer it is made of (a ptrmask, say)
  counted as holding what goes into it. The search now goes on past such
  a value as needed, as it does past an address computation.
- An intrinsic that reads memory and returns what it read (a masked load
  or gather) was taken for arithmetic. It now brings its value in like
  a load.
- A vector of pointers inside an aggregate did not count as a pointer.
  typeHasPointers and the pointer fields of an aggregate include it now.

And two costs of the previous commits:

- A float or double field of an aggregate that may hold an integer
  pointer got a slot of its own: 551 in D2's module, none of which can
  hold a reference in Go. Such a field now counts only when an address is
  computed from the value.
- A loop that only shortened a string (length arithmetic) counted as
  stepping its pointer. The search for a step follows only values that
  can hold an address.

What the pass does not cover is now written down, in findCarriers and
selfDerived: pieces of a pointer narrower than a word; a float made from
a pointer by a conversion and carried round a loop; a mark that GVN keeps
on a load whose bits are also read as a pointer; and a pointer that
a callee or memory moves past the end of its object's data (p = step(p),
a stepped variable captured by a closure). The last is what the rules of
package unsafe forbid; an object's header follows its data, so the end of
the data is still inside the object. TinyGo's original pass kept every
allocation in a slot for the whole function, so such code could get away
with it there and cannot here.

Tests in gc-slotliveness.ll: trackedMask, maskedLoad, vectorField,
doubleField (no slot), stringShortened (no slot for the start value).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alixander alixander changed the title [do not merge] GC stack slots by liveness: unsound as is GC stack slots by liveness Nov 26, 2026
@alixander
alixander marked this pull request as ready for review November 26, 2026 15:03
@alixander
alixander merged commit b33aa3a into d2 Nov 26, 2026
alixander added a commit that referenced this pull request Nov 26, 2026
GC stack slots by liveness (#1): a pointer gets a slot only while
a collection can find it in use. D2's WebAssembly module is 10,558,431
bytes and 3,570,072 after brotli, against 11,159,250 and 3,728,122 with
0.44.0-d2.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alixander added a commit to d2lang/d2 that referenced this pull request Nov 26, 2026
v0.44.0-d2.3 gives each pointer a GC stack slot only while a collection
can find it in use (d2lang/tinygo#1). The D2.js module is 601 KB
smaller, 10,558,431 bytes (158 KB smaller with Brotli), and renders
about 15% faster, with identical harness output; test-wasm.sh and the
d2.js tests pass with it.

ci/install-wasm-tools.sh installs it, and d2js/js/README.md and both
THIRD_PARTY_NOTICES copies name it. The changelogs now say the module
is less than half the size and takes less than half the time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant