mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-21 23:12:03 -07:00
Fix #2329
This commit is contained in:
@@ -2304,7 +2304,15 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
break;
|
break;
|
||||||
case BuiltinProc_volatile_store: LLVMSetVolatile(instr, true); break;
|
case BuiltinProc_volatile_store: LLVMSetVolatile(instr, true); break;
|
||||||
case BuiltinProc_atomic_store: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break;
|
case BuiltinProc_atomic_store: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break;
|
||||||
case BuiltinProc_atomic_store_explicit: LLVMSetOrdering(instr, llvm_atomic_ordering_from_odin(ce->args[2])); break;
|
case BuiltinProc_atomic_store_explicit:
|
||||||
|
{
|
||||||
|
auto ordering = llvm_atomic_ordering_from_odin(ce->args[2]);
|
||||||
|
LLVMSetOrdering(instr, ordering);
|
||||||
|
if (ordering == LLVMAtomicOrderingUnordered) {
|
||||||
|
LLVMSetVolatile(instr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type)));
|
LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type)));
|
||||||
@@ -2330,7 +2338,15 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
break;
|
break;
|
||||||
case BuiltinProc_volatile_load: LLVMSetVolatile(instr, true); break;
|
case BuiltinProc_volatile_load: LLVMSetVolatile(instr, true); break;
|
||||||
case BuiltinProc_atomic_load: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break;
|
case BuiltinProc_atomic_load: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break;
|
||||||
case BuiltinProc_atomic_load_explicit: LLVMSetOrdering(instr, llvm_atomic_ordering_from_odin(ce->args[1])); break;
|
case BuiltinProc_atomic_load_explicit:
|
||||||
|
{
|
||||||
|
auto ordering = llvm_atomic_ordering_from_odin(ce->args[1]);
|
||||||
|
LLVMSetOrdering(instr, ordering);
|
||||||
|
if (ordering == LLVMAtomicOrderingUnordered) {
|
||||||
|
LLVMSetVolatile(instr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type)));
|
LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type)));
|
||||||
|
|
||||||
@@ -2400,6 +2416,9 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
lbValue res = {};
|
lbValue res = {};
|
||||||
res.value = LLVMBuildAtomicRMW(p->builder, op, dst.value, val.value, ordering, false);
|
res.value = LLVMBuildAtomicRMW(p->builder, op, dst.value, val.value, ordering, false);
|
||||||
res.type = tv.type;
|
res.type = tv.type;
|
||||||
|
if (ordering == LLVMAtomicOrderingUnordered) {
|
||||||
|
LLVMSetVolatile(res.value, true);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2425,7 +2444,6 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
case BuiltinProc_atomic_compare_exchange_weak_explicit: success_ordering = llvm_atomic_ordering_from_odin(ce->args[3]); failure_ordering = llvm_atomic_ordering_from_odin(ce->args[4]); weak = true; break;
|
case BuiltinProc_atomic_compare_exchange_weak_explicit: success_ordering = llvm_atomic_ordering_from_odin(ce->args[3]); failure_ordering = llvm_atomic_ordering_from_odin(ce->args[4]); weak = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bill): Figure out how to make it weak
|
|
||||||
LLVMBool single_threaded = false;
|
LLVMBool single_threaded = false;
|
||||||
|
|
||||||
LLVMValueRef value = LLVMBuildAtomicCmpXchg(
|
LLVMValueRef value = LLVMBuildAtomicCmpXchg(
|
||||||
@@ -2436,6 +2454,9 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
single_threaded
|
single_threaded
|
||||||
);
|
);
|
||||||
LLVMSetWeak(value, weak);
|
LLVMSetWeak(value, weak);
|
||||||
|
if (success_ordering == LLVMAtomicOrderingUnordered || failure_ordering == LLVMAtomicOrderingUnordered) {
|
||||||
|
LLVMSetVolatile(value, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_type_tuple(tv.type)) {
|
if (is_type_tuple(tv.type)) {
|
||||||
Type *fix_typed = alloc_type_tuple();
|
Type *fix_typed = alloc_type_tuple();
|
||||||
|
|||||||
Reference in New Issue
Block a user