| ... | @@ -4458,8 +4458,14 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn | ... | @@ -4458,8 +4458,14 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn |
| 4458 | return LLVMBuildSelect(g->builder, success_bit, LLVMConstNull(get_llvm_type(g, child_type)), payload_val, ""); | 4458 | return LLVMBuildSelect(g->builder, success_bit, LLVMConstNull(get_llvm_type(g, child_type)), payload_val, ""); |
| 4459 | } | 4459 | } |
| 4460 | | 4460 | |
| | 4461 | // When the cmpxchg is discarded, the result location will have no bits. |
| | 4462 | if (!type_has_bits(instruction->result_loc->value.type)) { |
| | 4463 | return nullptr; |
| | 4464 | } |
| | 4465 | |
| 4461 | LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc); | 4466 | LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc); |
| 4462 | assert(type_has_bits(child_type)); | 4467 | src_assert(result_loc != nullptr, instruction->base.source_node); |
| | 4468 | src_assert(type_has_bits(child_type), instruction->base.source_node); |
| 4463 | | 4469 | |
| 4464 | LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, ""); | 4470 | LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, ""); |
| 4465 | LLVMValueRef val_ptr = LLVMBuildStructGEP(g->builder, result_loc, maybe_child_index, ""); | 4471 | LLVMValueRef val_ptr = LLVMBuildStructGEP(g->builder, result_loc, maybe_child_index, ""); |