| author | |
| committer | |
| log | 014cc60a72ac2d64935bf424459b5fa13e281ed9 |
| tree | 7f8c43d42297bb52e39366bb45084f7ee6662ae3 |
| parent | ee263a15cc8fb52c2ac6053a29168fb15089839b |
| signature |
and have it print llvm's internal timing info5 files changed, 21 insertions(+), 7 deletions(-)
src/all_types.hpp+1| ... | @@ -1727,6 +1727,7 @@ struct CodeGen { | ... | @@ -1727,6 +1727,7 @@ struct CodeGen { |
| 1727 | bool error_during_imports; | 1727 | bool error_during_imports; |
| 1728 | bool generate_error_name_table; | 1728 | bool generate_error_name_table; |
| 1729 | bool enable_cache; | 1729 | bool enable_cache; |
| 1730 | bool enable_time_report; | ||
| 1730 | 1731 | ||
| 1731 | //////////////////////////// Participates in Input Parameter Cache Hash | 1732 | //////////////////////////// Participates in Input Parameter Cache Hash |
| 1732 | ZigList<LinkLib *> link_libs_list; | 1733 | ZigList<LinkLib *> link_libs_list; |
src/codegen.cpp+6-3| ... | @@ -6398,7 +6398,8 @@ static void zig_llvm_emit_output(CodeGen *g) { | ... | @@ -6398,7 +6398,8 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 6398 | switch (g->emit_file_type) { | 6398 | switch (g->emit_file_type) { |
| 6399 | case EmitFileTypeBinary: | 6399 | case EmitFileTypeBinary: |
| 6400 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), | 6400 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), |
| 6401 | ZigLLVM_EmitBinary, &err_msg, g->build_mode == BuildModeDebug, is_small)) | 6401 | ZigLLVM_EmitBinary, &err_msg, g->build_mode == BuildModeDebug, is_small, |
| 6402 | g->enable_time_report)) | ||
| 6402 | { | 6403 | { |
| 6403 | zig_panic("unable to write object file %s: %s", buf_ptr(output_path), err_msg); | 6404 | zig_panic("unable to write object file %s: %s", buf_ptr(output_path), err_msg); |
| 6404 | } | 6405 | } |
| ... | @@ -6408,7 +6409,8 @@ static void zig_llvm_emit_output(CodeGen *g) { | ... | @@ -6408,7 +6409,8 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 6408 | 6409 | ||
| 6409 | case EmitFileTypeAssembly: | 6410 | case EmitFileTypeAssembly: |
| 6410 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), | 6411 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), |
| 6411 | ZigLLVM_EmitAssembly, &err_msg, g->build_mode == BuildModeDebug, is_small)) | 6412 | ZigLLVM_EmitAssembly, &err_msg, g->build_mode == BuildModeDebug, is_small, |
| 6413 | g->enable_time_report)) | ||
| 6412 | { | 6414 | { |
| 6413 | zig_panic("unable to write assembly file %s: %s", buf_ptr(output_path), err_msg); | 6415 | zig_panic("unable to write assembly file %s: %s", buf_ptr(output_path), err_msg); |
| 6414 | } | 6416 | } |
| ... | @@ -6417,7 +6419,8 @@ static void zig_llvm_emit_output(CodeGen *g) { | ... | @@ -6417,7 +6419,8 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 6417 | 6419 | ||
| 6418 | case EmitFileTypeLLVMIr: | 6420 | case EmitFileTypeLLVMIr: |
| 6419 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), | 6421 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), |
| 6420 | ZigLLVM_EmitLLVMIr, &err_msg, g->build_mode == BuildModeDebug, is_small)) | 6422 | ZigLLVM_EmitLLVMIr, &err_msg, g->build_mode == BuildModeDebug, is_small, |
| 6423 | g->enable_time_report)) | ||
| 6421 | { | 6424 | { |
| 6422 | zig_panic("unable to write llvm-ir file %s: %s", buf_ptr(output_path), err_msg); | 6425 | zig_panic("unable to write llvm-ir file %s: %s", buf_ptr(output_path), err_msg); |
| 6423 | } | 6426 | } |
src/main.cpp+4-2| ... | @@ -37,7 +37,7 @@ static int usage(const char *arg0) { | ... | @@ -37,7 +37,7 @@ static int usage(const char *arg0) { |
| 37 | " --cache [auto|off|on] build to the global cache and print output path to stdout\n" | 37 | " --cache [auto|off|on] build to the global cache and print output path to stdout\n" |
| 38 | " --color [auto|off|on] enable or disable colored error messages\n" | 38 | " --color [auto|off|on] enable or disable colored error messages\n" |
| 39 | " --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n" | 39 | " --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n" |
| 40 | " --enable-timing-info print timing diagnostics\n" | 40 | " -ftime-report print timing diagnostics\n" |
| 41 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" | 41 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" |
| 42 | " --name [name] override output name\n" | 42 | " --name [name] override output name\n" |
| 43 | " --output [file] override destination path\n" | 43 | " --output [file] override destination path\n" |
| ... | @@ -402,6 +402,7 @@ int main(int argc, char **argv) { | ... | @@ -402,6 +402,7 @@ int main(int argc, char **argv) { |
| 402 | os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path); | 402 | os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path); |
| 403 | 403 | ||
| 404 | CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf); | 404 | CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf); |
| 405 | g->enable_time_report = timing_info; | ||
| 405 | buf_init_from_str(&g->cache_dir, cache_dir); | 406 | buf_init_from_str(&g->cache_dir, cache_dir); |
| 406 | codegen_set_out_name(g, buf_create_from_str("build")); | 407 | codegen_set_out_name(g, buf_create_from_str("build")); |
| 407 | 408 | ||
| ... | @@ -533,7 +534,7 @@ int main(int argc, char **argv) { | ... | @@ -533,7 +534,7 @@ int main(int argc, char **argv) { |
| 533 | no_rosegment_workaround = true; | 534 | no_rosegment_workaround = true; |
| 534 | } else if (strcmp(arg, "--each-lib-rpath") == 0) { | 535 | } else if (strcmp(arg, "--each-lib-rpath") == 0) { |
| 535 | each_lib_rpath = true; | 536 | each_lib_rpath = true; |
| 536 | } else if (strcmp(arg, "--enable-timing-info") == 0) { | 537 | } else if (strcmp(arg, "-ftime-report") == 0) { |
| 537 | timing_info = true; | 538 | timing_info = true; |
| 538 | } else if (strcmp(arg, "--test-cmd-bin") == 0) { | 539 | } else if (strcmp(arg, "--test-cmd-bin") == 0) { |
| 539 | test_exec_args.append(nullptr); | 540 | test_exec_args.append(nullptr); |
| ... | @@ -828,6 +829,7 @@ int main(int argc, char **argv) { | ... | @@ -828,6 +829,7 @@ int main(int argc, char **argv) { |
| 828 | Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); | 829 | Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); |
| 829 | 830 | ||
| 830 | CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); | 831 | CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); |
| 832 | g->enable_time_report = timing_info; | ||
| 831 | buf_init_from_str(&g->cache_dir, cache_dir); | 833 | buf_init_from_str(&g->cache_dir, cache_dir); |
| 832 | codegen_set_out_name(g, buf_out_name); | 834 | codegen_set_out_name(g, buf_out_name); |
| 833 | codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); | 835 | codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); |
src/zig_llvm.cpp+8-1| ... | @@ -30,6 +30,7 @@ | ... | @@ -30,6 +30,7 @@ |
| 30 | #include <llvm/PassRegistry.h> | 30 | #include <llvm/PassRegistry.h> |
| 31 | #include <llvm/Support/FileSystem.h> | 31 | #include <llvm/Support/FileSystem.h> |
| 32 | #include <llvm/Support/TargetParser.h> | 32 | #include <llvm/Support/TargetParser.h> |
| 33 | #include <llvm/Support/Timer.h> | ||
| 33 | #include <llvm/Support/raw_ostream.h> | 34 | #include <llvm/Support/raw_ostream.h> |
| 34 | #include <llvm/Target/TargetMachine.h> | 35 | #include <llvm/Target/TargetMachine.h> |
| 35 | #include <llvm/Transforms/Coroutines.h> | 36 | #include <llvm/Transforms/Coroutines.h> |
| ... | @@ -81,8 +82,11 @@ static const bool assertions_on = false; | ... | @@ -81,8 +82,11 @@ static const bool assertions_on = false; |
| 81 | #endif | 82 | #endif |
| 82 | 83 | ||
| 83 | bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, | 84 | bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 84 | const char *filename, ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, bool is_small) | 85 | const char *filename, ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, |
| 86 | bool is_small, bool time_report) | ||
| 85 | { | 87 | { |
| 88 | TimePassesIsEnabled = time_report; | ||
| 89 | |||
| 86 | std::error_code EC; | 90 | std::error_code EC; |
| 87 | raw_fd_ostream dest(filename, EC, sys::fs::F_None); | 91 | raw_fd_ostream dest(filename, EC, sys::fs::F_None); |
| 88 | if (EC) { | 92 | if (EC) { |
| ... | @@ -182,6 +186,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM | ... | @@ -182,6 +186,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 182 | } | 186 | } |
| 183 | } | 187 | } |
| 184 | 188 | ||
| 189 | if (time_report) { | ||
| 190 | TimerGroup::printAll(errs()); | ||
| 191 | } | ||
| 185 | return false; | 192 | return false; |
| 186 | } | 193 | } |
| 187 | 194 |
src/zig_llvm.h+2-1| ... | @@ -55,7 +55,8 @@ enum ZigLLVM_EmitOutputType { | ... | @@ -55,7 +55,8 @@ enum ZigLLVM_EmitOutputType { |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, | 57 | ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 58 | const char *filename, enum ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, bool is_small); | 58 | const char *filename, enum ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, |
| 59 | bool is_small, bool time_report); | ||
| 59 | 60 | ||
| 60 | ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref); | 61 | ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref); |
| 61 | 62 |