github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/goroutine-wasm-asyncify.ll (about) 1 ; ModuleID = 'goroutine.go' 2 source_filename = "goroutine.go" 3 target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20" 4 target triple = "wasm32-unknown-wasi" 5 6 %runtime._string = type { ptr, i32 } 7 8 @"main$string" = internal unnamed_addr constant [4 x i8] c"test", align 1 9 10 ; Function Attrs: allockind("alloc,zeroed") allocsize(0) 11 declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0 12 13 declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1 14 15 ; Function Attrs: nounwind 16 define hidden void @main.init(ptr %context) unnamed_addr #2 { 17 entry: 18 ret void 19 } 20 21 ; Function Attrs: nounwind 22 define hidden void @main.regularFunctionGoroutine(ptr %context) unnamed_addr #2 { 23 entry: 24 call void @"internal/task.start"(i32 ptrtoint (ptr @"main.regularFunction$gowrapper" to i32), ptr nonnull inttoptr (i32 5 to ptr), i32 65536, ptr undef) #9 25 ret void 26 } 27 28 declare void @main.regularFunction(i32, ptr) #1 29 30 declare void @runtime.deadlock(ptr) #1 31 32 ; Function Attrs: nounwind 33 define linkonce_odr void @"main.regularFunction$gowrapper"(ptr %0) unnamed_addr #3 { 34 entry: 35 %unpack.int = ptrtoint ptr %0 to i32 36 call void @main.regularFunction(i32 %unpack.int, ptr undef) #9 37 call void @runtime.deadlock(ptr undef) #9 38 unreachable 39 } 40 41 declare void @"internal/task.start"(i32, ptr, i32, ptr) #1 42 43 ; Function Attrs: nounwind 44 define hidden void @main.inlineFunctionGoroutine(ptr %context) unnamed_addr #2 { 45 entry: 46 call void @"internal/task.start"(i32 ptrtoint (ptr @"main.inlineFunctionGoroutine$1$gowrapper" to i32), ptr nonnull inttoptr (i32 5 to ptr), i32 65536, ptr undef) #9 47 ret void 48 } 49 50 ; Function Attrs: nounwind 51 define internal void @"main.inlineFunctionGoroutine$1"(i32 %x, ptr %context) unnamed_addr #2 { 52 entry: 53 ret void 54 } 55 56 ; Function Attrs: nounwind 57 define linkonce_odr void @"main.inlineFunctionGoroutine$1$gowrapper"(ptr %0) unnamed_addr #4 { 58 entry: 59 %unpack.int = ptrtoint ptr %0 to i32 60 call void @"main.inlineFunctionGoroutine$1"(i32 %unpack.int, ptr undef) 61 call void @runtime.deadlock(ptr undef) #9 62 unreachable 63 } 64 65 ; Function Attrs: nounwind 66 define hidden void @main.closureFunctionGoroutine(ptr %context) unnamed_addr #2 { 67 entry: 68 %stackalloc = alloca i8, align 1 69 %n = call dereferenceable(4) ptr @runtime.alloc(i32 4, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #9 70 call void @runtime.trackPointer(ptr nonnull %n, ptr nonnull %stackalloc, ptr undef) #9 71 store i32 3, ptr %n, align 4 72 call void @runtime.trackPointer(ptr nonnull %n, ptr nonnull %stackalloc, ptr undef) #9 73 call void @runtime.trackPointer(ptr nonnull @"main.closureFunctionGoroutine$1", ptr nonnull %stackalloc, ptr undef) #9 74 %0 = call dereferenceable(8) ptr @runtime.alloc(i32 8, ptr null, ptr undef) #9 75 call void @runtime.trackPointer(ptr nonnull %0, ptr nonnull %stackalloc, ptr undef) #9 76 store i32 5, ptr %0, align 4 77 %1 = getelementptr inbounds { i32, ptr }, ptr %0, i32 0, i32 1 78 store ptr %n, ptr %1, align 4 79 call void @"internal/task.start"(i32 ptrtoint (ptr @"main.closureFunctionGoroutine$1$gowrapper" to i32), ptr nonnull %0, i32 65536, ptr undef) #9 80 %2 = load i32, ptr %n, align 4 81 call void @runtime.printint32(i32 %2, ptr undef) #9 82 ret void 83 } 84 85 ; Function Attrs: nounwind 86 define internal void @"main.closureFunctionGoroutine$1"(i32 %x, ptr %context) unnamed_addr #2 { 87 entry: 88 store i32 7, ptr %context, align 4 89 ret void 90 } 91 92 ; Function Attrs: nounwind 93 define linkonce_odr void @"main.closureFunctionGoroutine$1$gowrapper"(ptr %0) unnamed_addr #5 { 94 entry: 95 %1 = load i32, ptr %0, align 4 96 %2 = getelementptr inbounds { i32, ptr }, ptr %0, i32 0, i32 1 97 %3 = load ptr, ptr %2, align 4 98 call void @"main.closureFunctionGoroutine$1"(i32 %1, ptr %3) 99 call void @runtime.deadlock(ptr undef) #9 100 unreachable 101 } 102 103 declare void @runtime.printint32(i32, ptr) #1 104 105 ; Function Attrs: nounwind 106 define hidden void @main.funcGoroutine(ptr %fn.context, ptr %fn.funcptr, ptr %context) unnamed_addr #2 { 107 entry: 108 %stackalloc = alloca i8, align 1 109 %0 = call dereferenceable(12) ptr @runtime.alloc(i32 12, ptr null, ptr undef) #9 110 call void @runtime.trackPointer(ptr nonnull %0, ptr nonnull %stackalloc, ptr undef) #9 111 store i32 5, ptr %0, align 4 112 %1 = getelementptr inbounds { i32, ptr, ptr }, ptr %0, i32 0, i32 1 113 store ptr %fn.context, ptr %1, align 4 114 %2 = getelementptr inbounds { i32, ptr, ptr }, ptr %0, i32 0, i32 2 115 store ptr %fn.funcptr, ptr %2, align 4 116 call void @"internal/task.start"(i32 ptrtoint (ptr @main.funcGoroutine.gowrapper to i32), ptr nonnull %0, i32 65536, ptr undef) #9 117 ret void 118 } 119 120 ; Function Attrs: nounwind 121 define linkonce_odr void @main.funcGoroutine.gowrapper(ptr %0) unnamed_addr #6 { 122 entry: 123 %1 = load i32, ptr %0, align 4 124 %2 = getelementptr inbounds { i32, ptr, ptr }, ptr %0, i32 0, i32 1 125 %3 = load ptr, ptr %2, align 4 126 %4 = getelementptr inbounds { i32, ptr, ptr }, ptr %0, i32 0, i32 2 127 %5 = load ptr, ptr %4, align 4 128 call void %5(i32 %1, ptr %3) #9 129 call void @runtime.deadlock(ptr undef) #9 130 unreachable 131 } 132 133 ; Function Attrs: nounwind 134 define hidden void @main.recoverBuiltinGoroutine(ptr %context) unnamed_addr #2 { 135 entry: 136 ret void 137 } 138 139 ; Function Attrs: nounwind 140 define hidden void @main.copyBuiltinGoroutine(ptr %dst.data, i32 %dst.len, i32 %dst.cap, ptr %src.data, i32 %src.len, i32 %src.cap, ptr %context) unnamed_addr #2 { 141 entry: 142 %copy.n = call i32 @runtime.sliceCopy(ptr %dst.data, ptr %src.data, i32 %dst.len, i32 %src.len, i32 1, ptr undef) #9 143 ret void 144 } 145 146 declare i32 @runtime.sliceCopy(ptr nocapture writeonly, ptr nocapture readonly, i32, i32, i32, ptr) #1 147 148 ; Function Attrs: nounwind 149 define hidden void @main.closeBuiltinGoroutine(ptr dereferenceable_or_null(32) %ch, ptr %context) unnamed_addr #2 { 150 entry: 151 call void @runtime.chanClose(ptr %ch, ptr undef) #9 152 ret void 153 } 154 155 declare void @runtime.chanClose(ptr dereferenceable_or_null(32), ptr) #1 156 157 ; Function Attrs: nounwind 158 define hidden void @main.startInterfaceMethod(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 159 entry: 160 %stackalloc = alloca i8, align 1 161 %0 = call dereferenceable(16) ptr @runtime.alloc(i32 16, ptr null, ptr undef) #9 162 call void @runtime.trackPointer(ptr nonnull %0, ptr nonnull %stackalloc, ptr undef) #9 163 store ptr %itf.value, ptr %0, align 4 164 %1 = getelementptr inbounds { ptr, %runtime._string, ptr }, ptr %0, i32 0, i32 1 165 store ptr @"main$string", ptr %1, align 4 166 %.repack1 = getelementptr inbounds { ptr, %runtime._string, ptr }, ptr %0, i32 0, i32 1, i32 1 167 store i32 4, ptr %.repack1, align 4 168 %2 = getelementptr inbounds { ptr, %runtime._string, ptr }, ptr %0, i32 0, i32 2 169 store ptr %itf.typecode, ptr %2, align 4 170 call void @"internal/task.start"(i32 ptrtoint (ptr @"interface:{Print:func:{basic:string}{}}.Print$invoke$gowrapper" to i32), ptr nonnull %0, i32 65536, ptr undef) #9 171 ret void 172 } 173 174 declare void @"interface:{Print:func:{basic:string}{}}.Print$invoke"(ptr, ptr, i32, ptr, ptr) #7 175 176 ; Function Attrs: nounwind 177 define linkonce_odr void @"interface:{Print:func:{basic:string}{}}.Print$invoke$gowrapper"(ptr %0) unnamed_addr #8 { 178 entry: 179 %1 = load ptr, ptr %0, align 4 180 %2 = getelementptr inbounds { ptr, ptr, i32, ptr }, ptr %0, i32 0, i32 1 181 %3 = load ptr, ptr %2, align 4 182 %4 = getelementptr inbounds { ptr, ptr, i32, ptr }, ptr %0, i32 0, i32 2 183 %5 = load i32, ptr %4, align 4 184 %6 = getelementptr inbounds { ptr, ptr, i32, ptr }, ptr %0, i32 0, i32 3 185 %7 = load ptr, ptr %6, align 4 186 call void @"interface:{Print:func:{basic:string}{}}.Print$invoke"(ptr %1, ptr %3, i32 %5, ptr %7, ptr undef) #9 187 call void @runtime.deadlock(ptr undef) #9 188 unreachable 189 } 190 191 attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 192 attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 193 attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 194 attributes #3 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-gowrapper"="main.regularFunction" } 195 attributes #4 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-gowrapper"="main.inlineFunctionGoroutine$1" } 196 attributes #5 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-gowrapper"="main.closureFunctionGoroutine$1" } 197 attributes #6 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-gowrapper" } 198 attributes #7 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-invoke"="reflect/methods.Print(string)" "tinygo-methods"="reflect/methods.Print(string)" } 199 attributes #8 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-gowrapper"="interface:{Print:func:{basic:string}{}}.Print$invoke" } 200 attributes #9 = { nounwind }