aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-07-14 23:50:09 +0100
committergingerBill <bill@gingerbill.org>2020-07-14 23:50:09 +0100
commit13e5cb8cc4f9ef7745d4fb6436309d8bcfdcba13 (patch)
tree50ec4252390f01afde10fa4fe65abd52ce0013cc /src
parent7ae54ae3b4141ff0136ce9a1684bc16e7d994b41 (diff)
Fix #691 and Fix #692
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp46
-rw-r--r--src/llvm_backend.cpp24
2 files changed, 63 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 83a512d7d..0fa842852 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -2845,6 +2845,52 @@ irDebugInfo *ir_add_debug_info_type(irModule *module, Type *type, Entity *e, irD
return di;
}
+ if (is_type_relative_pointer(type)) {
+ Type *base_integer = base_type(type)->RelativePointer.base_integer;
+ base_integer = core_type(base_integer);
+ GB_ASSERT(base_integer->kind == Type_Basic);
+ irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_BasicType);
+ di->BasicType.encoding = ir_debug_encoding_for_basic(base_integer->Basic.kind);
+ di->BasicType.name = base_integer->Basic.name;
+ di->BasicType.size = ir_debug_size_bits(type);
+ di->BasicType.align = ir_debug_align_bits(type);
+ map_set(&module->debug_info, hash_type(type), di);
+ return di;
+ }
+
+ if (is_type_relative_slice(type)) {
+ Type *base_integer = base_type(type)->RelativeSlice.base_integer;
+ base_integer = core_type(base_integer);
+
+ // NOTE(lachsinc): Every slice type has its own composite type / field debug infos created. This is sorta wasteful.
+ irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompositeType);
+ di->CompositeType.name = str_lit("relative slice");
+ di->CompositeType.tag = irDebugBasicEncoding_structure_type;
+ di->CompositeType.size = ir_debug_size_bits(type); // TODO(lachsinc): Correct ??
+ di->CompositeType.align = ir_debug_align_bits(type);
+ map_set(&module->debug_info, hash_type(type), di);
+
+ irDebugInfo *data_di = ir_add_debug_info_field_internal(module, str_lit("data"), base_integer,
+ 0,
+ nullptr,
+ di);
+ map_set(&module->debug_info, hash_pointer(data_di), data_di);
+
+ irDebugInfo *len_di = ir_add_debug_info_field_internal(module, str_lit("len"), base_integer,
+ data_di->DerivedType.size,
+ nullptr,
+ di);
+ map_set(&module->debug_info, hash_pointer(len_di), len_di);
+
+ irDebugInfo *elements_di = ir_add_debug_info_array(module, 0, 2);
+ array_add(&elements_di->DebugInfoArray.elements, data_di);
+ array_add(&elements_di->DebugInfoArray.elements, len_di);
+ di->CompositeType.elements = elements_di;
+ map_set(&module->debug_info, hash_pointer(elements_di), elements_di);
+
+ return di;
+ }
+
GB_PANIC("Unreachable %s", type_to_string(type));
return nullptr;
}
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;
}
}