aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_debug.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2023-01-01 13:26:43 +0000
committerGitHub <noreply@github.com>2023-01-01 13:26:43 +0000
commit28fb35f2f7a6ffd75e76dd95352f4194d79b3166 (patch)
treeeac021b897fe6525a076264d5545aac6c96cfbb5 /src/llvm_backend_debug.cpp
parent547c7bce1b28757415c553830a18d94636cedbf8 (diff)
parentc1384afe2fd705ce075277aa8dc6bc259dc94cdc (diff)
Merge pull request #2263 from odin-lang/compiler-improvements-2022-12
Compiler Improvements for 2022-12
Diffstat (limited to 'src/llvm_backend_debug.cpp')
-rw-r--r--src/llvm_backend_debug.cpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp
index 65cefcd39..55c4370a2 100644
--- a/src/llvm_backend_debug.cpp
+++ b/src/llvm_backend_debug.cpp
@@ -1,4 +1,4 @@
-LLVMMetadataRef lb_get_llvm_metadata(lbModule *m, void *key) {
+gb_internal LLVMMetadataRef lb_get_llvm_metadata(lbModule *m, void *key) {
if (key == nullptr) {
return nullptr;
}
@@ -8,20 +8,14 @@ LLVMMetadataRef lb_get_llvm_metadata(lbModule *m, void *key) {
}
return nullptr;
}
-void lb_set_llvm_metadata(lbModule *m, void *key, LLVMMetadataRef value) {
+gb_internal void lb_set_llvm_metadata(lbModule *m, void *key, LLVMMetadataRef value) {
if (key != nullptr) {
map_set(&m->debug_values, key, value);
}
}
-LLVMMetadataRef lb_get_llvm_file_metadata_from_node(lbModule *m, Ast *node) {
- if (node == nullptr) {
- return nullptr;
- }
- return lb_get_llvm_metadata(m, node->file());
-}
-LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) {
+gb_internal LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) {
GB_ASSERT_MSG(p->debug_info != nullptr, "missing debug information for %.*s", LIT(p->name));
for (isize i = p->scope_stack.count-1; i >= 0; i--) {
@@ -34,21 +28,21 @@ LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) {
return p->debug_info;
}
-LLVMMetadataRef lb_debug_location_from_token_pos(lbProcedure *p, TokenPos pos) {
+gb_internal LLVMMetadataRef lb_debug_location_from_token_pos(lbProcedure *p, TokenPos pos) {
LLVMMetadataRef scope = lb_get_current_debug_scope(p);
GB_ASSERT_MSG(scope != nullptr, "%.*s", LIT(p->name));
return LLVMDIBuilderCreateDebugLocation(p->module->ctx, cast(unsigned)pos.line, cast(unsigned)pos.column, scope, nullptr);
}
-LLVMMetadataRef lb_debug_location_from_ast(lbProcedure *p, Ast *node) {
+gb_internal LLVMMetadataRef lb_debug_location_from_ast(lbProcedure *p, Ast *node) {
GB_ASSERT(node != nullptr);
return lb_debug_location_from_token_pos(p, ast_token(node).pos);
}
-LLVMMetadataRef lb_debug_end_location_from_ast(lbProcedure *p, Ast *node) {
+gb_internal LLVMMetadataRef lb_debug_end_location_from_ast(lbProcedure *p, Ast *node) {
GB_ASSERT(node != nullptr);
return lb_debug_location_from_token_pos(p, ast_end_token(node).pos);
}
-LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) {
+gb_internal LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) {
i64 size = type_size_of(type); // Check size
gb_unused(size);
@@ -93,7 +87,7 @@ LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) {
return LLVMDIBuilderCreateSubroutineType(m->debug_builder, file, parameters, parameter_count, flags);
}
-LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *type, u64 offset_in_bits) {
+gb_internal LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *type, u64 offset_in_bits) {
unsigned field_line = 1;
LLVMDIFlags field_flags = LLVMDIFlagZero;
@@ -107,7 +101,7 @@ LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *typ
field_flags, lb_debug_type(m, type)
);
}
-LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_in_bits, u32 align_in_bits, LLVMMetadataRef *elements, unsigned element_count) {
+gb_internal LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_in_bits, u32 align_in_bits, LLVMMetadataRef *elements, unsigned element_count) {
AstPackage *pkg = m->info->runtime_package;
GB_ASSERT(pkg->files.count != 0);
LLVMMetadataRef file = lb_get_llvm_metadata(m, pkg->files[0]);
@@ -117,7 +111,7 @@ LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_
}
-LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 size_in_bits, LLVMDWARFTypeEncoding encoding, LLVMDIFlags flags = LLVMDIFlagZero) {
+gb_internal LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 size_in_bits, LLVMDWARFTypeEncoding encoding, LLVMDIFlags flags = LLVMDIFlagZero) {
LLVMMetadataRef basic_type = LLVMDIBuilderCreateBasicType(m->debug_builder, cast(char const *)name.text, name.len, size_in_bits, encoding, flags);
#if 1
LLVMMetadataRef final_decl = LLVMDIBuilderCreateTypedef(m->debug_builder, basic_type, cast(char const *)name.text, name.len, nullptr, 0, nullptr, cast(u32)size_in_bits);
@@ -127,7 +121,7 @@ LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 si
#endif
}
-LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
+gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
i64 size = type_size_of(type); // Check size
gb_unused(size);
@@ -474,7 +468,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
return nullptr;
}
-LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) {
+gb_internal LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) {
LLVMMetadataRef found = nullptr;
for (;;) {
if (scope == nullptr) {
@@ -496,7 +490,7 @@ LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) {
}
}
-LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) {
+gb_internal LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) {
GB_ASSERT(type != nullptr);
LLVMMetadataRef found = lb_get_llvm_metadata(m, type);
if (found != nullptr) {
@@ -615,7 +609,7 @@ LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) {
return dt;
}
-void lb_debug_complete_types(lbModule *m) {
+gb_internal void lb_debug_complete_types(lbModule *m) {
/* unsigned const word_size = cast(unsigned)build_context.word_size; */
unsigned const word_bits = cast(unsigned)(8*build_context.word_size);
@@ -962,7 +956,7 @@ void lb_debug_complete_types(lbModule *m) {
-void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token) {
+gb_internal void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token) {
if (p->debug_info == nullptr) {
return;
}
@@ -1024,7 +1018,7 @@ void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T
LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block);
}
-void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block, lbArgKind arg_kind) {
+gb_internal void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block, lbArgKind arg_kind) {
if (p->debug_info == nullptr) {
return;
}
@@ -1097,7 +1091,7 @@ void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T
}
-void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) {
+gb_internal void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) {
if (!p->debug_info || !p->body) {
return;
}
@@ -1125,7 +1119,7 @@ void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) {
}
-String debug_info_mangle_constant_name(Entity *e, bool *did_allocate_) {
+gb_internal String debug_info_mangle_constant_name(Entity *e, bool *did_allocate_) {
String name = e->token.string;
if (e->pkg && e->pkg->name.len > 0) {
// NOTE(bill): C++ NONSENSE FOR DEBUG SHITE!
@@ -1135,7 +1129,7 @@ String debug_info_mangle_constant_name(Entity *e, bool *did_allocate_) {
return name;
}
-void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMetadataRef dtype, LLVMMetadataRef expr) {
+gb_internal void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMetadataRef dtype, LLVMMetadataRef expr) {
LLVMMetadataRef scope = nullptr;
LLVMMetadataRef file = nullptr;
unsigned line = 0;
@@ -1151,7 +1145,7 @@ void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMe
expr, decl, 8/*AlignInBits*/);
}
-void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLVMMetadataRef dtype, i64 v) {
+gb_internal void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLVMMetadataRef dtype, i64 v) {
LLVMMetadataRef expr = LLVMDIBuilderCreateConstantValueExpression(m->debug_builder, v);
bool did_allocate = false;
@@ -1167,7 +1161,7 @@ void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLV
}
}
-void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) {
+gb_internal void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) {
if (e == nullptr || e->kind != Entity_Constant) {
return;
}