diff options
| author | gingerBill <bill@gingerbill.org> | 2020-07-14 23:50:09 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-07-14 23:50:09 +0100 |
| commit | 13e5cb8cc4f9ef7745d4fb6436309d8bcfdcba13 (patch) | |
| tree | 50ec4252390f01afde10fa4fe65abd52ce0013cc /src/llvm_backend.cpp | |
| parent | 7ae54ae3b4141ff0136ce9a1684bc16e7d994b41 (diff) | |
Fix #691 and Fix #692
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index c9cb000b0..734003065 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -7977,15 +7977,25 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, } // TODO(bill): Figure out how to make it weak - LLVMBool single_threaded = !weak; + LLVMBool single_threaded = weak; + + LLVMValueRef value = LLVMBuildAtomicCmpXchg( + p->builder, address.value, + old_value.value, new_value.value, + success_ordering, + failure_ordering, + single_threaded + ); + + GB_ASSERT(tv.type->kind == Type_Tuple); + Type *fix_typed = alloc_type_tuple(); + array_init(&fix_typed->Tuple.variables, heap_allocator(), 2); + fix_typed->Tuple.variables[0] = tv.type->Tuple.variables[0]; + fix_typed->Tuple.variables[1] = alloc_entity_field(nullptr, blank_token, t_llvm_bool, false, 1); lbValue res = {}; - res.value = LLVMBuildAtomicCmpXchg(p->builder, address.value, - old_value.value, new_value.value, - success_ordering, - failure_ordering, - single_threaded); - res.type = tv.type; + res.value = value; + res.type = fix_typed; return res; } } |