mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-10 06:53:03 +00:00
Remove llc/opt hack. XX.bc now contains useful debug info thanks to removal of optimization flags in debug builds.
This commit is contained in:
@@ -573,10 +573,23 @@ void init_build_context(void) {
|
||||
|
||||
bc->optimization_level = gb_clamp(bc->optimization_level, 0, 3);
|
||||
|
||||
gbString opt_flags = gb_string_make_reserve(heap_allocator(), 16);
|
||||
gbString opt_flags = gb_string_make_reserve(heap_allocator(), 64);
|
||||
opt_flags = gb_string_append_fmt(opt_flags, "-O%d ", bc->optimization_level);
|
||||
if (bc->optimization_level != 0) {
|
||||
opt_flags = gb_string_append_fmt(opt_flags, "-O%d", bc->optimization_level);
|
||||
// NOTE(lachsinc): The following options were previously passed during call
|
||||
// to opt in main.cpp:exec_llvm_opt().
|
||||
// -die: Dead instruction elimination
|
||||
// -memcpyopt: MemCpy optimization
|
||||
opt_flags = gb_string_appendc(opt_flags, "-memcpyopt -die ");
|
||||
}
|
||||
|
||||
// NOTE(lachsinc): This optimization option was previously required to get
|
||||
// around an issue in fmt.odin. Thank bp for tracking it down! Leaving for now until the issue
|
||||
// is resolved and confirmed by Bill. Maybe it should be readded in non-debug builds.
|
||||
// if (bc->ODIN_DEBUG == false) {
|
||||
// opt_flags = gb_string_appendc(opt_flags, "-mem2reg ");
|
||||
// }
|
||||
|
||||
bc->opt_flags = make_string_c(opt_flags);
|
||||
|
||||
|
||||
|
||||
20
src/main.cpp
20
src/main.cpp
@@ -661,16 +661,10 @@ void remove_temp_files(String output_base) {
|
||||
}
|
||||
|
||||
i32 exec_llvm_opt(String output_base) {
|
||||
// NOTE(lachsinc): See note below in exec_llvm_llc.
|
||||
if (build_context.ODIN_DEBUG == true) return 0;
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
// For more passes arguments: http://llvm.org/docs/Passes.html
|
||||
return system_exec_command_line_app("llvm-opt", false,
|
||||
"\"%.*sbin/opt\" \"%.*s.ll\" -o \"%.*s.bc\" %.*s "
|
||||
"-mem2reg "
|
||||
"-memcpyopt "
|
||||
"-die "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
LIT(output_base), LIT(output_base),
|
||||
@@ -680,9 +674,6 @@ i32 exec_llvm_opt(String output_base) {
|
||||
// with the Windows version, while they will be system-provided on MacOS and GNU/Linux
|
||||
return system_exec_command_line_app("llvm-opt", false,
|
||||
"opt \"%.*s.ll\" -o \"%.*s.bc\" %.*s "
|
||||
"-mem2reg "
|
||||
"-memcpyopt "
|
||||
"-die "
|
||||
"",
|
||||
LIT(output_base), LIT(output_base),
|
||||
LIT(build_context.opt_flags));
|
||||
@@ -690,21 +681,15 @@ i32 exec_llvm_opt(String output_base) {
|
||||
}
|
||||
|
||||
i32 exec_llvm_llc(String output_base) {
|
||||
// NOTE(lachsinc): HACK!! opt.exe seems to strip away CodeView/PDB symbols regardless of
|
||||
// To get around this we will use the non-optimized (.ll) version during debug build.
|
||||
// There's probably better way to deal with this involving arguments or passing
|
||||
// additional things (.ll file) into llc.
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
||||
return system_exec_command_line_app("llvm-llc", false,
|
||||
"\"%.*sbin\\llc\" \"%.*s%s\" -filetype=obj -O%d "
|
||||
"\"%.*sbin\\llc\" \"%.*s.bc\" -filetype=obj -O%d "
|
||||
"-o \"%.*s.obj\" "
|
||||
"%.*s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
LIT(output_base),
|
||||
build_context.ODIN_DEBUG ? ".ll" : ".bc",
|
||||
build_context.optimization_level,
|
||||
LIT(output_base),
|
||||
LIT(build_context.llc_flags));
|
||||
@@ -712,12 +697,11 @@ i32 exec_llvm_llc(String output_base) {
|
||||
// NOTE(zangent): Linux / Unix is unfinished and not tested very well.
|
||||
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
||||
return system_exec_command_line_app("llc", false,
|
||||
"llc \"%.*s%s\" -filetype=obj -relocation-model=pic -O%d "
|
||||
"llc \"%.*s.bc\" -filetype=obj -relocation-model=pic -O%d "
|
||||
"%.*s "
|
||||
"%s"
|
||||
"",
|
||||
LIT(output_base),
|
||||
build_context.ODIN_DEBUG ? ".ll" : ".bc",
|
||||
build_context.optimization_level,
|
||||
LIT(build_context.llc_flags),
|
||||
str_eq_ignore_case(cross_compile_target, str_lit("Essence")) ? "-mtriple=x86_64-pc-none-elf" : "");
|
||||
|
||||
Reference in New Issue
Block a user