| ... | ... | @@ -2727,7 +2727,13 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode |
| 2727 | 2727 | IrInstruction *result_ptr = ir_build_load_ptr(irb, scope, node, irb->exec->coro_result_ptr_field_ptr); |
| 2728 | 2728 | ir_build_store_ptr(irb, scope, node, result_ptr, return_value); |
| 2729 | 2729 | } |
| 2730 | | IrInstruction *maybe_await_handle = ir_build_load_ptr(irb, scope, node, irb->exec->coro_awaiter_field_ptr); |
| 2730 | IrInstruction *promise_type_val = ir_build_const_type(irb, scope, node, |
| 2731 | get_maybe_type(irb->codegen, irb->codegen->builtin_types.entry_promise)); |
| 2732 | // TODO replace replacement_value with @intToPtr(?promise, 0x1) when it doesn't crash zig |
| 2733 | IrInstruction *replacement_value = irb->exec->coro_handle; |
| 2734 | IrInstruction *maybe_await_handle = ir_build_atomic_rmw(irb, scope, node, |
| 2735 | promise_type_val, irb->exec->coro_awaiter_field_ptr, nullptr, replacement_value, nullptr, |
| 2736 | AtomicRmwOp_xchg, AtomicOrderSeqCst); |
| 2731 | 2737 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node, maybe_await_handle); |
| 2732 | 2738 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, false); |
| 2733 | 2739 | return ir_build_cond_br(irb, scope, node, is_non_null, irb->exec->coro_normal_final, irb->exec->coro_early_final, |
| ... | ... | @@ -17433,8 +17439,12 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr |
| 17433 | 17439 | return ira->codegen->builtin_types.entry_invalid; |
| 17434 | 17440 | |
| 17435 | 17441 | AtomicRmwOp op; |
| 17436 | | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->other, &op)) { |
| 17437 | | return ira->codegen->builtin_types.entry_invalid; |
| 17442 | if (instruction->op == nullptr) { |
| 17443 | op = instruction->resolved_op; |
| 17444 | } else { |
| 17445 | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->other, &op)) { |
| 17446 | return ira->codegen->builtin_types.entry_invalid; |
| 17447 | } |
| 17438 | 17448 | } |
| 17439 | 17449 | |
| 17440 | 17450 | IrInstruction *operand = instruction->operand->other; |
| ... | ... | @@ -17446,8 +17456,12 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr |
| 17446 | 17456 | return ira->codegen->builtin_types.entry_invalid; |
| 17447 | 17457 | |
| 17448 | 17458 | AtomicOrder ordering; |
| 17449 | | if (!ir_resolve_atomic_order(ira, instruction->ordering->other, &ordering)) |
| 17450 | | return ira->codegen->builtin_types.entry_invalid; |
| 17459 | if (instruction->ordering == nullptr) { |
| 17460 | ordering = instruction->resolved_ordering; |
| 17461 | } else { |
| 17462 | if (!ir_resolve_atomic_order(ira, instruction->ordering->other, &ordering)) |
| 17463 | return ira->codegen->builtin_types.entry_invalid; |
| 17464 | } |
| 17451 | 17465 | |
| 17452 | 17466 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar) |
| 17453 | 17467 | { |