mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Fix build times for -o:<string> in LLVM-17
This commit is contained in:
@@ -1336,10 +1336,6 @@ gb_internal void check_proc_group_decl(CheckerContext *ctx, Entity *pg_entity, D
|
|||||||
is_invalid = true;
|
is_invalid = true;
|
||||||
break;
|
break;
|
||||||
case ProcOverload_Polymorphic:
|
case ProcOverload_Polymorphic:
|
||||||
#if 0
|
|
||||||
error(p->token, "Overloaded procedure '%.*s' has a polymorphic counterpart in the procedure group '%.*s' which is not allowed", LIT(name), LIT(proc_group_name));
|
|
||||||
is_invalid = true;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case ProcOverload_ParamCount:
|
case ProcOverload_ParamCount:
|
||||||
case ProcOverload_ParamTypes:
|
case ProcOverload_ParamTypes:
|
||||||
|
|||||||
@@ -3673,18 +3673,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ
|
|||||||
ExactValue b = y->value;
|
ExactValue b = y->value;
|
||||||
|
|
||||||
if (!is_type_constant_type(x->type)) {
|
if (!is_type_constant_type(x->type)) {
|
||||||
#if 0
|
|
||||||
gbString xt = type_to_string(x->type);
|
|
||||||
gbString err_str = expr_to_string(node);
|
|
||||||
error(op, "Invalid type, '%s', for constant binary expression '%s'", xt, err_str);
|
|
||||||
gb_string_free(err_str);
|
|
||||||
gb_string_free(xt);
|
|
||||||
x->mode = Addressing_Invalid;
|
|
||||||
#else
|
|
||||||
// NOTE(bill, 2021-04-21): The above is literally a useless error message.
|
|
||||||
// Why did I add it in the first place?!
|
|
||||||
x->mode = Addressing_Value;
|
x->mode = Addressing_Value;
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1056,24 +1056,6 @@ gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_t
|
|||||||
} else {
|
} else {
|
||||||
Type *elem = check_type_expr(c, bs->elem, nullptr);
|
Type *elem = check_type_expr(c, bs->elem, nullptr);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (named_type != nullptr && named_type->kind == Type_Named &&
|
|
||||||
elem->kind == Type_Enum) {
|
|
||||||
// NOTE(bill): Anonymous enumeration
|
|
||||||
|
|
||||||
String prefix = named_type->Named.name;
|
|
||||||
String enum_name = concatenate_strings(heap_allocator(), prefix, str_lit(".enum"));
|
|
||||||
|
|
||||||
Token token = make_token_ident(enum_name);
|
|
||||||
|
|
||||||
Entity *e = alloc_entity_type_name(nullptr, token, nullptr, EntityState_Resolved);
|
|
||||||
Type *named = alloc_type_named(enum_name, elem, e);
|
|
||||||
e->type = named;
|
|
||||||
e->TypeName.is_type_alias = true;
|
|
||||||
elem = named;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
type->BitSet.elem = elem;
|
type->BitSet.elem = elem;
|
||||||
if (!is_type_valid_bit_set_elem(elem)) {
|
if (!is_type_valid_bit_set_elem(elem)) {
|
||||||
error(bs->elem, "Expected an enum type for a bit_set");
|
error(bs->elem, "Expected an enum type for a bit_set");
|
||||||
|
|||||||
+15
-15
@@ -1025,6 +1025,8 @@ gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) {
|
|||||||
LLVMSetLinkage(p->value, LLVMInternalLinkage);
|
LLVMSetLinkage(p->value, LLVMInternalLinkage);
|
||||||
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "nounwind");
|
lb_add_attribute_to_proc(m, p->value, "nounwind");
|
||||||
|
lb_add_attribute_to_proc(m, p->value, "optnone");
|
||||||
|
lb_add_attribute_to_proc(m, p->value, "noinline");
|
||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
@@ -1086,6 +1088,8 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc
|
|||||||
|
|
||||||
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type);
|
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type);
|
||||||
p->is_startup = true;
|
p->is_startup = true;
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "optnone");
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "noinline");
|
||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
@@ -1189,6 +1193,8 @@ gb_internal lbProcedure *lb_create_cleanup_runtime(lbModule *main_module) { // C
|
|||||||
|
|
||||||
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_CLEANUP_RUNTIME_PROC_NAME), proc_type);
|
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_CLEANUP_RUNTIME_PROC_NAME), proc_type);
|
||||||
p->is_startup = true;
|
p->is_startup = true;
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "optnone");
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "noinline");
|
||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
@@ -1396,6 +1402,8 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
|
|||||||
lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default;
|
lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default;
|
||||||
if (p->flags & lbProcedureFlag_WithoutMemcpyPass) {
|
if (p->flags & lbProcedureFlag_WithoutMemcpyPass) {
|
||||||
pass_manager_kind = lbFunctionPassManager_default_without_memcpy;
|
pass_manager_kind = lbFunctionPassManager_default_without_memcpy;
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "optnone");
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "noinline");
|
||||||
} else {
|
} else {
|
||||||
if (p->entity && p->entity->kind == Entity_Procedure) {
|
if (p->entity && p->entity->kind == Entity_Procedure) {
|
||||||
switch (p->entity->Procedure.optimization_mode) {
|
switch (p->entity->Procedure.optimization_mode) {
|
||||||
@@ -1405,6 +1413,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
|
|||||||
break;
|
break;
|
||||||
case ProcedureOptimizationMode_Size:
|
case ProcedureOptimizationMode_Size:
|
||||||
pass_manager_kind = lbFunctionPassManager_size;
|
pass_manager_kind = lbFunctionPassManager_size;
|
||||||
|
lb_add_attribute_to_proc(p->module, p->value, "optsize");
|
||||||
break;
|
break;
|
||||||
case ProcedureOptimizationMode_Speed:
|
case ProcedureOptimizationMode_Speed:
|
||||||
pass_manager_kind = lbFunctionPassManager_speed;
|
pass_manager_kind = lbFunctionPassManager_speed;
|
||||||
@@ -1463,22 +1472,12 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
|
|||||||
LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
|
LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
|
||||||
defer (LLVMDisposePassBuilderOptions(pb_options));
|
defer (LLVMDisposePassBuilderOptions(pb_options));
|
||||||
|
|
||||||
LLVMPassBuilderOptionsSetVerifyEach(pb_options, true);
|
|
||||||
|
|
||||||
// int inline_threshold = 0;
|
|
||||||
// LLVMPassBuilderOptionsSetInlinerThreshold(pb_options, inline_threshold);
|
|
||||||
|
|
||||||
if (build_context.optimization_level >= 2) {
|
|
||||||
LLVMPassBuilderOptionsSetLoopVectorization(pb_options, true);
|
|
||||||
LLVMPassBuilderOptionsSetLoopUnrolling (pb_options, true);
|
|
||||||
LLVMPassBuilderOptionsSetMergeFunctions (pb_options, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (build_context.optimization_level) {
|
switch (build_context.optimization_level) {
|
||||||
case -1:
|
case -1:
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
array_add(&passes, "default<O0>");
|
array_add(&passes, "always-inline");
|
||||||
|
array_add(&passes, "function(annotation-remarks)");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
array_add(&passes, "default<Os>");
|
array_add(&passes, "default<Os>");
|
||||||
@@ -1506,9 +1505,8 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
|
|||||||
array_add(&passes, "tsan");
|
array_add(&passes, "tsan");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (passes.count == 0) {
|
if (passes.count == 0) {
|
||||||
return 0;
|
array_add(&passes, "verify");
|
||||||
}
|
}
|
||||||
|
|
||||||
gbString passes_str = gb_string_make_reserve(heap_allocator(), 1024);
|
gbString passes_str = gb_string_make_reserve(heap_allocator(), 1024);
|
||||||
@@ -1520,7 +1518,10 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
|
|||||||
passes_str = gb_string_appendc(passes_str, passes[i]);
|
passes_str = gb_string_appendc(passes_str, passes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gb_printf_err("LLVMRunPasses [START]\n");
|
||||||
LLVMErrorRef llvm_err = LLVMRunPasses(wd->m->mod, passes_str, wd->target_machine, pb_options);
|
LLVMErrorRef llvm_err = LLVMRunPasses(wd->m->mod, passes_str, wd->target_machine, pb_options);
|
||||||
|
gb_printf_err("LLVMRunPasses [END]\n");
|
||||||
|
|
||||||
defer (LLVMConsumeError(llvm_err));
|
defer (LLVMConsumeError(llvm_err));
|
||||||
if (llvm_err != nullptr) {
|
if (llvm_err != nullptr) {
|
||||||
char *llvm_error = LLVMGetErrorMessage(llvm_err);
|
char *llvm_error = LLVMGetErrorMessage(llvm_err);
|
||||||
@@ -2547,7 +2548,6 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
|
|
||||||
TIME_SECTION("LLVM Module Verification");
|
TIME_SECTION("LLVM Module Verification");
|
||||||
|
|
||||||
|
|
||||||
if (!lb_llvm_module_verification(gen, do_threading)) {
|
if (!lb_llvm_module_verification(gen, do_threading)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,6 @@ gb_internal bool lb_is_const_or_global(lbValue value) {
|
|||||||
if (lb_is_const(value)) {
|
if (lb_is_const(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// TODO remove use of LLVMGetElementType
|
|
||||||
#if 0
|
|
||||||
if (LLVMGetValueKind(value.value) == LLVMGlobalVariableValueKind) {
|
|
||||||
LLVMTypeRef t = LLVMGetElementType(LLVMTypeOf(value.value));
|
|
||||||
if (!lb_is_type_kind(t, LLVMPointerTypeKind)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LLVMTypeRef elem = LLVMGetElementType(t);
|
|
||||||
return lb_is_type_kind(elem, LLVMFunctionTypeKind);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->body && entity->pkg && (entity->pkg->kind == Package_Normal) || (entity->pkg->kind == Package_Init)) {
|
if (p->body && entity->pkg && ((entity->pkg->kind == Package_Normal) || (entity->pkg->kind == Package_Init))) {
|
||||||
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
|
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
|
||||||
lb_add_attribute_to_proc(m, p->value, "sanitize_address");
|
lb_add_attribute_to_proc(m, p->value, "sanitize_address");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user