diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-04-22 18:11:50 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-04-22 18:11:50 -0400 |
| commit | 21767144fc1a8627a109e81a164c55171c279d82 (patch) | |
| tree | 99ba3c7ec18227fe0abc01da0335851ef8535358 /src/codegen.cpp | |
| parent | da2af9c613841552e9e47b6c9f0e9e4ee74894fb (diff) | |
| download | zig-21767144fc1a8627a109e81a164c55171c279d82.tar.gz zig-21767144fc1a8627a109e81a164c55171c279d82.zip | |
linux: support VDSO for clock_gettime
also fix a compiler crash when using cmpxchg with nullable pointer
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index b5c8fdecac..4581c3e2b3 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3561,6 +3561,16 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn LLVMValueRef result_val = ZigLLVMBuildCmpXchg(g->builder, ptr_val, cmp_val, new_val, success_order, failure_order, instruction->is_weak); + TypeTableEntry *maybe_type = instruction->base.value.type; + assert(maybe_type->id == TypeTableEntryIdMaybe); + TypeTableEntry *child_type = maybe_type->data.maybe.child_type; + + if (type_is_codegen_pointer(child_type)) { + LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, ""); + LLVMValueRef success_bit = LLVMBuildExtractValue(g->builder, result_val, 1, ""); + return LLVMBuildSelect(g->builder, success_bit, LLVMConstNull(child_type->type_ref), payload_val, ""); + } + assert(instruction->tmp_ptr != nullptr); assert(type_has_bits(instruction->type)); |
