aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-04-22 18:13:57 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-04-22 18:13:57 -0400
commit371a3ad4bd7b1fda56654f32b89c176a0197651f (patch)
tree9b402e02568e4f62a728a7cec1819363a89d6e9a /src/codegen.cpp
parent7af6ed3f20bbf0459ce6aed833c7e170ee6c927b (diff)
parent21767144fc1a8627a109e81a164c55171c279d82 (diff)
downloadzig-371a3ad4bd7b1fda56654f32b89c176a0197651f.tar.gz
zig-371a3ad4bd7b1fda56654f32b89c176a0197651f.zip
Merge branch 'tgschultz-std.os.time'
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp10
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));