Updated stats.

This commit is contained in:
Christoffer Lerno
2024-07-22 19:23:08 +02:00
parent 34fc9851bf
commit 237f7e7f1a
5 changed files with 54 additions and 65 deletions

View File

@@ -140,7 +140,7 @@ typedef enum
typedef enum
{
SINGLE_MODULE_NOT_SET = -1,
SINGLE_MODULE_OFF = 0,
SINGLE_MODULE_OFF = 0, // NOLINT
SINGLE_MODULE_ON = 1
} SingleModule;
@@ -217,7 +217,7 @@ typedef enum
typedef enum
{
STRUCT_RETURN_DEFAULT = -1,
STRUCT_RETURN_STACK = 0,
STRUCT_RETURN_STACK = 0, // NOLINT
STRUCT_RETURN_REG = 1
} StructReturn;
@@ -425,7 +425,6 @@ typedef struct BuildOptions_
bool print_project_properties;
bool print_manifest_properties;
bool print_precedence;
bool print_build_settings;
bool print_linking;
bool benchmarking;
bool testing;

View File

@@ -157,52 +157,6 @@ const char *decl_to_a_name(Decl *decl)
}
// Set the external name of a declaration
void decl_set_external_name(Decl *decl)
{
if (decl->decl_kind == DECL_ERASED) return;
// Already has the extname set using an attribute?
// if so we're done.
if (decl->has_extname) return;
const char *name = decl->name;
if (!name) name = "$anon";
// "extern" or the module has no prefix?
if (decl->is_extern || decl_module(decl)->no_extprefix)
{
assert(decl->name || decl_module(decl)->no_extprefix);
decl->extname = name;
return;
}
// Otherwise, first put the module name into the scratch buffer
scratch_buffer_clear();
Module *module = decl_module(decl);
const char *module_name = module->extname ? module->extname : module->name->module;
char c;
while ((c = *(module_name++)) != 0)
{
switch (c)
{
case ':':
scratch_buffer_append_char(decl->is_export ? '_' : '.');
module_name++;
break;
default:
scratch_buffer_append_char(c);
break;
}
}
// Concat with the name
scratch_buffer_append(decl->is_export ? "_" : ".");
scratch_buffer_append(name);
// Copy it to extname
decl->extname = scratch_buffer_copy();
}
Decl *decl_new_var(const char *name, SourceSpan loc, TypeInfo *type, VarDeclKind kind)
{
Decl *decl = decl_new(DECL_VAR, name, loc);

View File

@@ -268,14 +268,56 @@ static void compiler_print_bench(void)
{
if (debug_stats)
{
printf("Timings\n");
printf("-------\n");
if (compiler_init_time >= 0) printf("Initialization took: %.4f ms\n", compiler_init_time * 1000);
if (compiler_parsing_time >= 0) printf("Parsing took: %.4f ms\n", (compiler_parsing_time - compiler_init_time) * 1000);
if (compiler_sema_time >= 0) printf("Analysis took: %.4f ms\n", (compiler_sema_time - compiler_parsing_time) * 1000);
if (compiler_ir_gen_time >= 0) printf("Ir gen took: %.4f ms\n", (compiler_ir_gen_time - compiler_sema_time) * 1000);
if (compiler_codegen_time >= 0) printf("Codegen took: %.4f ms\n", (compiler_codegen_time - compiler_ir_gen_time) * 1000);
if (compiler_link_time >= 0) printf("Linking took: %f ms\n", (compiler_link_time - compiler_codegen_time) * 1000);
puts("--------- Compilation time statistics --------\n");
double last = compiler_init_time;
double parse_time = compiler_parsing_time - compiler_init_time;
if (compiler_parsing_time) last = compiler_parsing_time;
double sema_time = compiler_sema_time - compiler_parsing_time;
if (compiler_sema_time) last = compiler_sema_time;
double ir_time = compiler_ir_gen_time - compiler_sema_time;
if (compiler_ir_gen_time) last = compiler_ir_gen_time;
double codegen_time = compiler_codegen_time - compiler_ir_gen_time;
if (compiler_codegen_time) last = compiler_codegen_time;
double link_time = compiler_link_time - compiler_codegen_time;
if (compiler_link_time) last = compiler_link_time;
printf("Frontend -------------------- Time --- %% total\n");
if (compiler_init_time >= 0) printf("Initialization took: %10.3f ms %8.1f %%\n", compiler_init_time * 1000, compiler_init_time * 100 / last);
if (compiler_parsing_time >= 0) printf("Parsing took: %10.3f ms %8.1f %%\n", parse_time * 1000, parse_time * 100 / last);
if (compiler_sema_time >= 0)
{
printf("Analysis took: %10.3f ms %8.1f %%\n", sema_time * 1000, sema_time * 100 / last);
printf("TOTAL: %10.3f ms %8.1f %%\n", compiler_sema_time * 1000, compiler_sema_time * 100 / last);
puts("");
}
if (compiler_ir_gen_time >= 0)
{
printf("Backend --------------------- Time --- %% total\n");
printf("Ir gen took: %10.3f ms %8.1f %%\n", ir_time * 1000, ir_time * 100 / last);
if (compiler_codegen_time >= 0)
{
last = compiler_codegen_time;
if (active_target.build_threads > 1)
{
printf("Codegen took: %10.3f ms %8.1f %% (%d threads)\n", codegen_time * 1000, codegen_time * 100 / last, active_target.build_threads);
}
else
{
printf("Codegen took: %10.3f ms %8.1f %%\n", codegen_time * 1000, codegen_time * 100 / last);
}
}
if (compiler_link_time >= 0)
{
last = compiler_link_time;
printf("Linking took: %10.3f ms %8.1f %%\n", link_time * 1000, link_time * 100 / last);
}
printf("TOTAL: %10.3f ms %8.1f %%\n", (last - compiler_sema_time) * 1000, 100 - compiler_sema_time * 100 / last);
}
if (last)
{
puts("----------------------------------------------");
printf("TOTAL compile time: %.3f ms.\n", last * 1000);
puts("----------------------------------------------");
}
}
}
@@ -489,7 +531,7 @@ void compiler_compile(void)
}
#if USE_PTHREAD
INFO_LOG("Will use %d thread(s).", active_target.build_threads);
INFO_LOG("Will use %d thread(s).\n", active_target.build_threads);
#endif
unsigned task_count = vec_size(tasks);
if (task_count == 1)

View File

@@ -2217,7 +2217,7 @@ Decl *decl_new_ct(DeclKind kind, SourceSpan span);
Decl *decl_new_with_type(const char *name, SourceSpan span, DeclKind decl_type);
Decl *decl_new_var(const char *name, SourceSpan span, TypeInfo *type, VarDeclKind kind);
Decl *decl_new_generated_var(Type *type, VarDeclKind kind, SourceSpan span);
void decl_set_external_name(Decl *decl);
const char *decl_safe_name(Decl *decl);
const char *decl_to_name(Decl *decl);
const char *decl_to_a_name(Decl *decl);

View File

@@ -1059,12 +1059,6 @@ static char *arch_to_target_triple[ARCH_OS_TARGET_LAST + 1] = {
[WASM64] = "wasm64-unknown-unknown",
};
void target_destroy()
{
}
static bool arch_is_supported(ArchType arch)
{
switch (arch)