github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/interp/testdata/alloc.ll (about) 1 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 2 target triple = "wasm32--wasi" 3 4 @"runtime/gc.layout:62-2000000000000001" = linkonce_odr unnamed_addr constant { i32, [8 x i8] } { i32 62, [8 x i8] c"\01\00\00\00\00\00\00 " } 5 @pointerFree12 = global ptr null 6 @pointerFree7 = global ptr null 7 @pointerFree3 = global ptr null 8 @pointerFree0 = global ptr null 9 @layout1 = global ptr null 10 @layout2 = global ptr null 11 @layout3 = global ptr null 12 @layout4 = global ptr null 13 @bigobj1 = global ptr null 14 15 declare ptr @runtime.alloc(i32, ptr) unnamed_addr 16 17 define void @runtime.initAll() unnamed_addr { 18 call void @main.init() 19 ret void 20 } 21 22 define internal void @main.init() unnamed_addr { 23 ; Object that's word-aligned. 24 %pointerFree12 = call ptr @runtime.alloc(i32 12, ptr inttoptr (i32 3 to ptr)) 25 store ptr %pointerFree12, ptr @pointerFree12 26 ; Object larger than a word but not word-aligned. 27 %pointerFree7 = call ptr @runtime.alloc(i32 7, ptr inttoptr (i32 3 to ptr)) 28 store ptr %pointerFree7, ptr @pointerFree7 29 ; Object smaller than a word (and of course not word-aligned). 30 %pointerFree3 = call ptr @runtime.alloc(i32 3, ptr inttoptr (i32 3 to ptr)) 31 store ptr %pointerFree3, ptr @pointerFree3 32 ; Zero-sized object. 33 %pointerFree0 = call ptr @runtime.alloc(i32 0, ptr inttoptr (i32 3 to ptr)) 34 store ptr %pointerFree0, ptr @pointerFree0 35 36 ; Object made out of 3 pointers. 37 %layout1 = call ptr @runtime.alloc(i32 12, ptr inttoptr (i32 67 to ptr)) 38 store ptr %layout1, ptr @layout1 39 ; Array (or slice) of 5 slices. 40 %layout2 = call ptr @runtime.alloc(i32 60, ptr inttoptr (i32 71 to ptr)) 41 store ptr %layout2, ptr @layout2 42 ; Oddly shaped object, using all bits in the layout integer. 43 %layout3 = call ptr @runtime.alloc(i32 104, ptr inttoptr (i32 2467830261 to ptr)) 44 store ptr %layout3, ptr @layout3 45 ; ...repeated. 46 %layout4 = call ptr @runtime.alloc(i32 312, ptr inttoptr (i32 2467830261 to ptr)) 47 store ptr %layout4, ptr @layout4 48 49 ; Large object that needs to be stored in a separate global. 50 %bigobj1 = call ptr @runtime.alloc(i32 248, ptr @"runtime/gc.layout:62-2000000000000001") 51 store ptr %bigobj1, ptr @bigobj1 52 ret void 53 }