aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-07-08 15:13:40 +0100
committergingerBill <bill@gingerbill.org>2024-07-08 15:13:40 +0100
commit2a219fa8305f2d246d5b3ae5b2b1e25c75bb4332 (patch)
tree350669a755e9e0d8645f4ff5edf03cd1abb9254d /src
parent8491e2491cd6fe4ea1b5205614f43f1a525cb77f (diff)
Correct `-use-separate-module` behaviour
Diffstat (limited to 'src')
-rw-r--r--src/entity.cpp3
-rw-r--r--src/llvm_backend.cpp2
-rw-r--r--src/llvm_backend_general.cpp3
-rw-r--r--src/main.cpp7
-rw-r--r--src/timings.cpp7
5 files changed, 16 insertions, 6 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index 8f55c1faf..9dee9cbe7 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -338,6 +338,9 @@ gb_internal Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Typ
entity->token = token;
entity->type = type;
entity->id = 1 + global_entity_id.fetch_add(1);
+ if (token.pos.file_id) {
+ entity->file = thread_safe_get_ast_file_from_id(token.pos.file_id);
+ }
return entity;
}
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 8c82d7117..9818c5435 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -3439,7 +3439,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
gbString label_object_generation = gb_string_make(heap_allocator(), "LLVM Object Generation");
if (gen->modules.count > 1) {
- label_object_generation = gb_string_append_fmt(label_object_generation, " (%d modules)", gen->modules.count);
+ label_object_generation = gb_string_append_fmt(label_object_generation, " (%td modules)", gen->modules.count);
}
TIME_SECTION_WITH_LEN(label_object_generation, gb_string_length(label_object_generation));
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index f65bc9ac7..77f78a24c 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -118,6 +118,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
map_init(&gen->anonymous_proc_lits, 1024);
if (USE_SEPARATE_MODULES) {
+ bool module_per_file = build_context.module_per_file && build_context.optimization_level <= 0;
for (auto const &entry : gen->info->packages) {
AstPackage *pkg = entry.value;
auto m = gb_alloc_item(permanent_allocator(), lbModule);
@@ -125,7 +126,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
m->gen = gen;
map_set(&gen->modules, cast(void *)pkg, m);
lb_init_module(m, c);
- if (build_context.module_per_file) {
+ if (module_per_file) {
// NOTE(bill): Probably per file is not a good idea, so leave this for later
for (AstFile *file : pkg->files) {
auto m = gb_alloc_item(permanent_allocator(), lbModule);
diff --git a/src/main.cpp b/src/main.cpp
index 8ea0ae62c..89ce93b18 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3304,11 +3304,16 @@ int main(int arg_count, char const **arg_ptr) {
} else
#endif
{
- MAIN_TIME_SECTION("LLVM API Code Gen");
lbGenerator *gen = gb_alloc_item(permanent_allocator(), lbGenerator);
if (!lb_init_generator(gen, checker)) {
return 1;
}
+
+ gbString label_code_gen = gb_string_make(heap_allocator(), "LLVM API Code Gen");
+ if (gen->modules.count > 1) {
+ label_code_gen = gb_string_append_fmt(label_code_gen, " ( %4td modules )", gen->modules.count);
+ }
+ MAIN_TIME_SECTION_WITH_LEN(label_code_gen, gb_string_length(label_code_gen));
if (lb_generate_code(gen)) {
switch (build_context.build_mode) {
case BuildMode_Executable:
diff --git a/src/timings.cpp b/src/timings.cpp
index 712e804cb..3f8402b36 100644
--- a/src/timings.cpp
+++ b/src/timings.cpp
@@ -146,9 +146,10 @@ gb_internal f64 time_stamp_as_us(TimeStamp const &ts, u64 freq) {
return 1000000.0*time_stamp_as_s(ts, freq);
}
-#define MAIN_TIME_SECTION(str) do { debugf("[Section] %s\n", str); timings_start_section(&global_timings, str_lit(str)); } while (0)
-#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
-#define TIME_SECTION_WITH_LEN(str, len) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, make_string((u8 *)str, len)); } while (0)
+#define MAIN_TIME_SECTION(str) do { debugf("[Section] %s\n", str); timings_start_section(&global_timings, str_lit(str)); } while (0)
+#define MAIN_TIME_SECTION_WITH_LEN(str, len) do { debugf("[Section] %s\n", str); timings_start_section(&global_timings, make_string((u8 *)str, len)); } while (0)
+#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
+#define TIME_SECTION_WITH_LEN(str, len) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, make_string((u8 *)str, len)); } while (0)
enum TimingUnit {