43 lines
995 B
LLVM
43 lines
995 B
LLVM
; The loop body lends the borrow to a new task and passes it back to the header; the exit sees that handle through the header parameter, so ending the borrow before its join is rejected.
|
|
; expect: reject E4302
|
|
; phase: 3
|
|
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
|
module test.cfg_provenance_loan_backedge
|
|
air 0
|
|
lang 0.1
|
|
features [cancellation, effects, ownership, tasks]
|
|
|
|
fn @main() -> u8
|
|
effects [task.spawn, task.wait]
|
|
entry:
|
|
%x = local.alloc u8
|
|
local.zero %x
|
|
%r = borrow.ref %x
|
|
%sc = task.scope.begin
|
|
%t0 = task.spawn %sc, @zero()
|
|
br @head(%t0)
|
|
head(%t: task<u8>):
|
|
%c = const.bool false
|
|
cbr %c, @body(%t), @exit(%t)
|
|
body(%tb: task<u8>):
|
|
%old = task.join %tb
|
|
%t1 = task.spawn %sc, @rd(%r)
|
|
br @head(%t1)
|
|
exit(%te: task<u8>):
|
|
borrow.end %r
|
|
%v = task.join %te
|
|
task.scope.end %sc
|
|
ret %v
|
|
|
|
fn @rd(%p: ref<u8>) -> u8
|
|
effects []
|
|
entry:
|
|
%v = load %p
|
|
ret %v
|
|
|
|
fn @zero() -> u8
|
|
effects []
|
|
entry:
|
|
%z = const.u8 0
|
|
ret %z
|