| ... | @@ -6796,6 +6796,9 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6796,6 +6796,9 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6796 | ir_build_store_ptr(irb, scope, node, err_ret_trace_ptr_field_ptr, err_ret_trace_ptr); | 6796 | ir_build_store_ptr(irb, scope, node, err_ret_trace_ptr_field_ptr, err_ret_trace_ptr); |
| 6797 | } | 6797 | } |
| 6798 | | 6798 | |
| | 6799 | IrBasicBlock *already_awaited_block = ir_create_basic_block(irb, scope, "AlreadyAwaited"); |
| | 6800 | IrBasicBlock *not_awaited_block = ir_create_basic_block(irb, scope, "NotAwaited"); |
| | 6801 | |
| 6799 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); | 6802 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); |
| 6800 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, | 6803 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| 6801 | atomic_state_field_name); | 6804 | atomic_state_field_name); |
| ... | @@ -6823,6 +6826,15 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6823,6 +6826,15 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6823 | IrInstruction *prev_atomic_value = ir_build_atomic_rmw(irb, scope, node, | 6826 | IrInstruction *prev_atomic_value = ir_build_atomic_rmw(irb, scope, node, |
| 6824 | usize_type_val, atomic_state_ptr, nullptr, mask_bits, nullptr, | 6827 | usize_type_val, atomic_state_ptr, nullptr, mask_bits, nullptr, |
| 6825 | AtomicRmwOp_or, AtomicOrderSeqCst); | 6828 | AtomicRmwOp_or, AtomicOrderSeqCst); |
| | 6829 | |
| | 6830 | IrInstruction *is_awaited_value = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, await_mask, false); |
| | 6831 | IrInstruction *is_awaited_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, is_awaited_value, zero, false); |
| | 6832 | ir_build_cond_br(irb, scope, node, is_awaited_bool, already_awaited_block, not_awaited_block, const_bool_false); |
| | 6833 | |
| | 6834 | ir_set_cursor_at_end_and_append_block(irb, already_awaited_block); |
| | 6835 | ir_build_unreachable(irb, scope, node); |
| | 6836 | |
| | 6837 | ir_set_cursor_at_end_and_append_block(irb, not_awaited_block); |
| 6826 | IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); | 6838 | IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); |
| 6827 | IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false); | 6839 | IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false); |
| 6828 | IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend"); | 6840 | IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend"); |