@@ -6,7 +6,7 @@ target triple = "wasm32-unknown-wasi"
66%runtime.channelOp = type { ptr , ptr , i32 , ptr }
77%runtime.chanSelectState = type { ptr , ptr }
88
9- declare void @runtime.trackPointer (ptr nocapture readonly , ptr , ptr ) #0
9+ declare void @runtime.trackPointer (ptr readonly captures(none) , ptr , ptr ) #0
1010
1111; Function Attrs: nounwind
1212define hidden void @main.init (ptr %context ) unnamed_addr #1 {
@@ -19,33 +19,33 @@ define hidden void @main.chanIntSend(ptr dereferenceable_or_null(36) %ch, ptr %c
1919entry:
2020 %chan.op = alloca %runtime.channelOp , align 8
2121 %chan.value = alloca i32 , align 4
22- call void @llvm.lifetime.start.p0 (i64 4 , ptr nonnull %chan.value )
22+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.value )
2323 store i32 3 , ptr %chan.value , align 4
24- call void @llvm.lifetime.start.p0 (i64 16 , ptr nonnull %chan.op )
24+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.op )
2525 call void @runtime.chanSend (ptr %ch , ptr nonnull %chan.value , ptr nonnull %chan.op , ptr undef ) #3
26- call void @llvm.lifetime.end.p0 (i64 16 , ptr nonnull %chan.op )
27- call void @llvm.lifetime.end.p0 (i64 4 , ptr nonnull %chan.value )
26+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.op )
27+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.value )
2828 ret void
2929}
3030
3131; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
32- declare void @llvm.lifetime.start.p0 (i64 immarg, ptr nocapture ) #2
32+ declare void @llvm.lifetime.start.p0 (ptr captures(none) ) #2
3333
3434declare void @runtime.chanSend (ptr dereferenceable_or_null (36 ), ptr , ptr dereferenceable_or_null (16 ), ptr ) #0
3535
3636; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
37- declare void @llvm.lifetime.end.p0 (i64 immarg, ptr nocapture ) #2
37+ declare void @llvm.lifetime.end.p0 (ptr captures(none) ) #2
3838
3939; Function Attrs: nounwind
4040define hidden void @main.chanIntRecv (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
4141entry:
4242 %chan.op = alloca %runtime.channelOp , align 8
4343 %chan.value = alloca i32 , align 4
44- call void @llvm.lifetime.start.p0 (i64 4 , ptr nonnull %chan.value )
45- call void @llvm.lifetime.start.p0 (i64 16 , ptr nonnull %chan.op )
44+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.value )
45+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.op )
4646 %0 = call i1 @runtime.chanRecv (ptr %ch , ptr nonnull %chan.value , ptr nonnull %chan.op , ptr undef ) #3
47- call void @llvm.lifetime.end.p0 (i64 4 , ptr nonnull %chan.value )
48- call void @llvm.lifetime.end.p0 (i64 16 , ptr nonnull %chan.op )
47+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.value )
48+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.op )
4949 ret void
5050}
5151
@@ -55,19 +55,19 @@ declare i1 @runtime.chanRecv(ptr dereferenceable_or_null(36), ptr, ptr dereferen
5555define hidden void @main.chanZeroSend (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
5656entry:
5757 %chan.op = alloca %runtime.channelOp , align 8
58- call void @llvm.lifetime.start.p0 (i64 16 , ptr nonnull %chan.op )
58+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.op )
5959 call void @runtime.chanSend (ptr %ch , ptr null , ptr nonnull %chan.op , ptr undef ) #3
60- call void @llvm.lifetime.end.p0 (i64 16 , ptr nonnull %chan.op )
60+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.op )
6161 ret void
6262}
6363
6464; Function Attrs: nounwind
6565define hidden void @main.chanZeroRecv (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
6666entry:
6767 %chan.op = alloca %runtime.channelOp , align 8
68- call void @llvm.lifetime.start.p0 (i64 16 , ptr nonnull %chan.op )
68+ call void @llvm.lifetime.start.p0 (ptr nonnull %chan.op )
6969 %0 = call i1 @runtime.chanRecv (ptr %ch , ptr null , ptr nonnull %chan.op , ptr undef ) #3
70- call void @llvm.lifetime.end.p0 (i64 16 , ptr nonnull %chan.op )
70+ call void @llvm.lifetime.end.p0 (ptr nonnull %chan.op )
7171 ret void
7272}
7373
7777 %select.states.alloca = alloca [2 x %runtime.chanSelectState ], align 8
7878 %select.send.value = alloca i32 , align 4
7979 store i32 1 , ptr %select.send.value , align 4
80- call void @llvm.lifetime.start.p0 (i64 16 , ptr nonnull %select.states.alloca )
80+ call void @llvm.lifetime.start.p0 (ptr nonnull %select.states.alloca )
8181 store ptr %ch1 , ptr %select.states.alloca , align 4
8282 %select.states.alloca.repack1 = getelementptr inbounds nuw i8 , ptr %select.states.alloca , i32 4
8383 store ptr %select.send.value , ptr %select.states.alloca.repack1 , align 4
8686 %.repack3 = getelementptr inbounds nuw i8 , ptr %select.states.alloca , i32 12
8787 store ptr null , ptr %.repack3 , align 4
8888 %select.result = call { i32 , i1 } @runtime.chanSelect (ptr undef , ptr nonnull %select.states.alloca , i32 2 , i32 2 , ptr null , i32 0 , i32 0 , ptr undef ) #3
89- call void @llvm.lifetime.end.p0 (i64 16 , ptr nonnull %select.states.alloca )
89+ call void @llvm.lifetime.end.p0 (ptr nonnull %select.states.alloca )
9090 %1 = extractvalue { i32 , i1 } %select.result , 0
9191 %2 = icmp eq i32 %1 , 0
9292 br i1 %2 , label %select.done , label %select.next
@@ -104,6 +104,80 @@ select.body: ; preds = %select.next
104104
105105declare { i32 , i1 } @runtime.chanSelect (ptr , ptr , i32 , i32 , ptr , i32 , i32 , ptr ) #0
106106
107+ ; Function Attrs: nounwind
108+ define hidden i1 @main.selectNonBlockingSend (ptr dereferenceable_or_null (36 ) %ch , i32 %value , ptr %context ) unnamed_addr #1 {
109+ entry:
110+ %select.send.value = alloca i32 , align 4
111+ call void @llvm.lifetime.start.p0 (ptr nonnull %select.send.value )
112+ store i32 %value , ptr %select.send.value , align 4
113+ %select.sent = call i1 @runtime.chanTrySend (ptr %ch , ptr nonnull %select.send.value , ptr undef ) #3
114+ call void @llvm.lifetime.end.p0 (ptr nonnull %select.send.value )
115+ br i1 %select.sent , label %select.body , label %select.next
116+
117+ select .body: ; preds = %entry
118+ ret i1 true
119+
120+ select .next: ; preds = %entry
121+ ret i1 false
122+ }
123+
124+ declare i1 @runtime.chanTrySend (ptr dereferenceable_or_null (36 ), ptr , ptr ) #0
125+
126+ ; Function Attrs: nounwind
127+ define hidden { i32 , i1 , i1 } @main.selectNonBlockingRecv (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
128+ entry:
129+ %select.recvbuf = alloca i32 , align 4
130+ %stackalloc = alloca i8 , align 1
131+ call void @llvm.lifetime.start.p0 (ptr nonnull %select.recvbuf )
132+ %select.recv = call { i1 , i1 } @runtime.chanTryRecv (ptr %ch , ptr nonnull %select.recvbuf , ptr undef ) #3
133+ %select.received = extractvalue { i1 , i1 } %select.recv , 0
134+ call void @runtime.trackPointer (ptr nonnull %select.recvbuf , ptr nonnull %stackalloc , ptr undef ) #3
135+ br i1 %select.received , label %select.body , label %select.next
136+
137+ select .body: ; preds = %entry
138+ %select.recv.ok = extractvalue { i1 , i1 } %select.recv , 1
139+ %0 = load i32 , ptr %select.recvbuf , align 4
140+ %1 = insertvalue { i32 , i1 , i1 } zeroinitializer , i32 %0 , 0
141+ %2 = insertvalue { i32 , i1 , i1 } %1 , i1 %select.recv.ok , 1
142+ %3 = insertvalue { i32 , i1 , i1 } %2 , i1 true , 2
143+ ret { i32 , i1 , i1 } %3
144+
145+ select .next: ; preds = %entry
146+ ret { i32 , i1 , i1 } zeroinitializer
147+ }
148+
149+ declare { i1 , i1 } @runtime.chanTryRecv (ptr dereferenceable_or_null (36 ), ptr , ptr ) #0
150+
151+ ; Function Attrs: nounwind
152+ define hidden i1 @main.selectNonBlockingZeroSend (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
153+ entry:
154+ %select.sent = call i1 @runtime.chanTrySend (ptr %ch , ptr null , ptr undef ) #3
155+ br i1 %select.sent , label %select.body , label %select.next
156+
157+ select .body: ; preds = %entry
158+ ret i1 true
159+
160+ select .next: ; preds = %entry
161+ ret i1 false
162+ }
163+
164+ ; Function Attrs: nounwind
165+ define hidden { i1 , i1 } @main.selectNonBlockingZeroRecv (ptr dereferenceable_or_null (36 ) %ch , ptr %context ) unnamed_addr #1 {
166+ entry:
167+ %select.recv = call { i1 , i1 } @runtime.chanTryRecv (ptr %ch , ptr null , ptr undef ) #3
168+ %select.received = extractvalue { i1 , i1 } %select.recv , 0
169+ br i1 %select.received , label %select.body , label %select.next
170+
171+ select .body: ; preds = %entry
172+ %select.recv.ok = extractvalue { i1 , i1 } %select.recv , 1
173+ %0 = insertvalue { i1 , i1 } zeroinitializer , i1 %select.recv.ok , 0
174+ %1 = insertvalue { i1 , i1 } %0 , i1 true , 1
175+ ret { i1 , i1 } %1
176+
177+ select .next: ; preds = %entry
178+ ret { i1 , i1 } zeroinitializer
179+ }
180+
107181attributes #0 = { "target-features" ="+bulk-memory,+bulk-memory-opt,+call-indirect-overlong,+mutable-globals,+nontrapping-fptoint,+sign-ext,-multivalue,-reference-types" }
108182attributes #1 = { nounwind "target-features" ="+bulk-memory,+bulk-memory-opt,+call-indirect-overlong,+mutable-globals,+nontrapping-fptoint,+sign-ext,-multivalue,-reference-types" }
109183attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
0 commit comments