diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-02 14:47:26 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-02 14:47:26 -0400 |
| commit | 90e64bc620edc3f3c3a2c16d01b7ca2eefc02429 (patch) | |
| tree | 42280ec202a86a5fab37ed5b6e38f38792ab8042 /src | |
| parent | a5cb0f77d11bdcc504fe3e6afa928c88de821518 (diff) | |
| download | zig-90e64bc620edc3f3c3a2c16d01b7ca2eefc02429.tar.gz zig-90e64bc620edc3f3c3a2c16d01b7ca2eefc02429.zip | |
fix cmpxchg with discarded result
Diffstat (limited to 'src')
| -rw-r--r-- | src/codegen.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0ac945e8c2..ef24716dff 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4458,8 +4458,14 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn return LLVMBuildSelect(g->builder, success_bit, LLVMConstNull(get_llvm_type(g, child_type)), payload_val, ""); } + // When the cmpxchg is discarded, the result location will have no bits. + if (!type_has_bits(instruction->result_loc->value.type)) { + return nullptr; + } + LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc); - assert(type_has_bits(child_type)); + src_assert(result_loc != nullptr, instruction->base.source_node); + src_assert(type_has_bits(child_type), instruction->base.source_node); LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, ""); LLVMValueRef val_ptr = LLVMBuildStructGEP(g->builder, result_loc, maybe_child_index, ""); |
