mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-24 14:01:37 +00:00
@@ -464,6 +464,15 @@ enum IntegerDivisionByZeroKind : u8 {
|
||||
IntegerDivisionByZero_AllBits,
|
||||
};
|
||||
|
||||
// values of BuildContext.optimization_level;
|
||||
// matches Odin_Optimization_Mode in checker.cpp
|
||||
enum OptimizationLevel : i32 {
|
||||
OptimizationLevel_None = -1,
|
||||
OptimizationLevel_Minimal = 0,
|
||||
OptimizationLevel_Size = 1,
|
||||
OptimizationLevel_Speed = 2,
|
||||
OptimizationLevel_Aggressive = 3,
|
||||
};
|
||||
|
||||
// This stores the information for the specify architecture of this build
|
||||
struct BuildContext {
|
||||
|
||||
@@ -2438,6 +2438,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
|
||||
lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default;
|
||||
if (p->flags & lbProcedureFlag_WithoutMemcpyPass) {
|
||||
pass_manager_kind = lbFunctionPassManager_default_without_memcpy;
|
||||
lb_remove_attribute_from_proc(p->module, p->value, "optsize"); // incompatible with optnone
|
||||
lb_add_attribute_to_proc(p->module, p->value, "optnone");
|
||||
lb_add_attribute_to_proc(p->module, p->value, "noinline");
|
||||
} else {
|
||||
|
||||
@@ -3033,6 +3033,10 @@ gb_internal void lb_add_attribute_to_proc(lbModule *m, LLVMValueRef proc_value,
|
||||
LLVMAddAttributeAtIndex(proc_value, LLVMAttributeIndex_FunctionIndex, lb_create_enum_attribute(m->ctx, name, value));
|
||||
}
|
||||
|
||||
gb_internal void lb_remove_attribute_from_proc(lbModule *m, LLVMValueRef proc_value, char const *name) {
|
||||
LLVMRemoveEnumAttributeAtIndex(proc_value, LLVMAttributeIndex_FunctionIndex, LLVMGetEnumAttributeKindForName(name, gb_strlen(name)));
|
||||
}
|
||||
|
||||
gb_internal bool lb_proc_has_attribute(lbModule *m, LLVMValueRef proc_value, char const *name) {
|
||||
LLVMAttributeRef ref = LLVMGetEnumAttributeAtIndex(proc_value, LLVMAttributeIndex_FunctionIndex, LLVMGetEnumAttributeKindForName(name, gb_strlen(name)));
|
||||
return ref != nullptr;
|
||||
|
||||
@@ -213,6 +213,13 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
|
||||
case ProcedureOptimizationMode_FavorSize:
|
||||
lb_add_attribute_to_proc(m, p->value, "optsize");
|
||||
break;
|
||||
default:
|
||||
// need optsize per proc for -o:size;
|
||||
// (inliner, unroller, vectorizer, etc check it)
|
||||
if (build_context.optimization_level == OptimizationLevel_Size) {
|
||||
lb_add_attribute_to_proc(m, p->value, "optsize");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (pt->Proc.enable_target_feature.len != 0) {
|
||||
|
||||
Reference in New Issue
Block a user