aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_debug.cpp
diff options
context:
space:
mode:
authorkorvahkh <92224397+korvahkh@users.noreply.github.com>2024-06-13 01:27:44 +0000
committerGitHub <noreply@github.com>2024-06-13 01:27:44 +0000
commit104ca2ce22c269b71df08edb00cb26bee4daf59d (patch)
treeee0a3275d3b42ae9aa85d09bf01f278d3965cc31 /src/llvm_backend_debug.cpp
parenta7a6ff8c693be92929327660fd446dfc0af62e01 (diff)
parenta67df0739245d85e7aa773e7271a64121ca534c5 (diff)
Merge branch 'odin-lang:master' into fix-omitempty-comma
Diffstat (limited to 'src/llvm_backend_debug.cpp')
-rw-r--r--src/llvm_backend_debug.cpp53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp
index 2654a1d28..f1ace5f06 100644
--- a/src/llvm_backend_debug.cpp
+++ b/src/llvm_backend_debug.cpp
@@ -46,6 +46,15 @@ gb_internal LLVMMetadataRef lb_debug_end_location_from_ast(lbProcedure *p, Ast *
return lb_debug_location_from_token_pos(p, ast_end_token(node).pos);
}
+gb_internal void lb_debug_file_line(lbModule *m, Ast *node, LLVMMetadataRef *file, unsigned *line) {
+ if (*file == nullptr) {
+ if (node) {
+ *file = lb_get_llvm_metadata(m, node->file());
+ *line = cast(unsigned)ast_token(node).pos.line;
+ }
+ }
+}
+
gb_internal LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) {
i64 size = type_size_of(type); // Check size
gb_unused(size);
@@ -117,6 +126,8 @@ gb_internal LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &nam
gb_internal LLVMMetadataRef lb_debug_struct(lbModule *m, Type *type, Type *bt, String name, LLVMMetadataRef scope, LLVMMetadataRef file, unsigned line) {
GB_ASSERT(bt->kind == Type_Struct);
+ lb_debug_file_line(m, bt->Struct.node, &file, &line);
+
unsigned tag = DW_TAG_structure_type;
if (is_type_raw_union(bt)) {
tag = DW_TAG_union_type;
@@ -336,6 +347,8 @@ gb_internal LLVMMetadataRef lb_debug_union(lbModule *m, Type *type, String name,
Type *bt = base_type(type);
GB_ASSERT(bt->kind == Type_Union);
+ lb_debug_file_line(m, bt->Union.node, &file, &line);
+
u64 size_in_bits = 8*type_size_of(bt);
u32 align_in_bits = 8*cast(u32)type_align_of(bt);
@@ -415,6 +428,8 @@ gb_internal LLVMMetadataRef lb_debug_bitset(lbModule *m, Type *type, String name
Type *bt = base_type(type);
GB_ASSERT(bt->kind == Type_BitSet);
+ lb_debug_file_line(m, bt->BitSet.node, &file, &line);
+
u64 size_in_bits = 8*type_size_of(bt);
u32 align_in_bits = 8*cast(u32)type_align_of(bt);
@@ -494,6 +509,8 @@ gb_internal LLVMMetadataRef lb_debug_enum(lbModule *m, Type *type, String name,
Type *bt = base_type(type);
GB_ASSERT(bt->kind == Type_Enum);
+ lb_debug_file_line(m, bt->Enum.node, &file, &line);
+
u64 size_in_bits = 8*type_size_of(bt);
u32 align_in_bits = 8*cast(u32)type_align_of(bt);
@@ -609,50 +626,50 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
case Basic_complex32:
{
LLVMMetadataRef elements[2] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f16, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f16, 4);
+ elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f16, 0*16);
+ elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f16, 1*16);
return lb_debug_basic_struct(m, str_lit("complex32"), 64, 32, elements, gb_count_of(elements));
}
case Basic_complex64:
{
LLVMMetadataRef elements[2] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f32, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f32, 4);
+ elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f32, 0*32);
+ elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f32, 2*32);
return lb_debug_basic_struct(m, str_lit("complex64"), 64, 32, elements, gb_count_of(elements));
}
case Basic_complex128:
{
LLVMMetadataRef elements[2] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f64, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f64, 8);
+ elements[0] = lb_debug_struct_field(m, str_lit("real"), t_f64, 0*64);
+ elements[1] = lb_debug_struct_field(m, str_lit("imag"), t_f64, 1*64);
return lb_debug_basic_struct(m, str_lit("complex128"), 128, 64, elements, gb_count_of(elements));
}
case Basic_quaternion64:
{
LLVMMetadataRef elements[4] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f16, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f16, 4);
- elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f16, 8);
- elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f16, 12);
+ elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f16, 0*16);
+ elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f16, 1*16);
+ elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f16, 2*16);
+ elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f16, 3*16);
return lb_debug_basic_struct(m, str_lit("quaternion64"), 128, 32, elements, gb_count_of(elements));
}
case Basic_quaternion128:
{
LLVMMetadataRef elements[4] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f32, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f32, 4);
- elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f32, 8);
- elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f32, 12);
+ elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f32, 0*32);
+ elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f32, 1*32);
+ elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f32, 2*32);
+ elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f32, 3*32);
return lb_debug_basic_struct(m, str_lit("quaternion128"), 128, 32, elements, gb_count_of(elements));
}
case Basic_quaternion256:
{
LLVMMetadataRef elements[4] = {};
- elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f64, 0);
- elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f64, 8);
- elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f64, 16);
- elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f64, 24);
+ elements[0] = lb_debug_struct_field(m, str_lit("imag"), t_f64, 0*64);
+ elements[1] = lb_debug_struct_field(m, str_lit("jmag"), t_f64, 1*64);
+ elements[2] = lb_debug_struct_field(m, str_lit("kmag"), t_f64, 2*64);
+ elements[3] = lb_debug_struct_field(m, str_lit("real"), t_f64, 3*64);
return lb_debug_basic_struct(m, str_lit("quaternion256"), 256, 32, elements, gb_count_of(elements));
}