diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-11 22:46:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-11 22:46:22 -0400 |
| commit | 014cc60a72ac2d64935bf424459b5fa13e281ed9 (patch) | |
| tree | 7f8c43d42297bb52e39366bb45084f7ee6662ae3 /src | |
| parent | ee263a15cc8fb52c2ac6053a29168fb15089839b (diff) | |
| download | zig-014cc60a72ac2d64935bf424459b5fa13e281ed9.tar.gz zig-014cc60a72ac2d64935bf424459b5fa13e281ed9.zip | |
rename --enable-timing-info to -ftime-report to match clang
and have it print llvm's internal timing info
Diffstat (limited to 'src')
| -rw-r--r-- | src/all_types.hpp | 1 | ||||
| -rw-r--r-- | src/codegen.cpp | 9 | ||||
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/zig_llvm.cpp | 9 | ||||
| -rw-r--r-- | src/zig_llvm.h | 3 |
5 files changed, 21 insertions, 7 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp index 3dfbc6ba7f..8aa2718d30 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1727,6 +1727,7 @@ struct CodeGen { bool error_during_imports; bool generate_error_name_table; bool enable_cache; + bool enable_time_report; //////////////////////////// Participates in Input Parameter Cache Hash ZigList<LinkLib *> link_libs_list; diff --git a/src/codegen.cpp b/src/codegen.cpp index aeb2b6edc4..6f21ceecab 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6398,7 +6398,8 @@ static void zig_llvm_emit_output(CodeGen *g) { switch (g->emit_file_type) { case EmitFileTypeBinary: if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), - ZigLLVM_EmitBinary, &err_msg, g->build_mode == BuildModeDebug, is_small)) + ZigLLVM_EmitBinary, &err_msg, g->build_mode == BuildModeDebug, is_small, + g->enable_time_report)) { zig_panic("unable to write object file %s: %s", buf_ptr(output_path), err_msg); } @@ -6408,7 +6409,8 @@ static void zig_llvm_emit_output(CodeGen *g) { case EmitFileTypeAssembly: if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), - ZigLLVM_EmitAssembly, &err_msg, g->build_mode == BuildModeDebug, is_small)) + ZigLLVM_EmitAssembly, &err_msg, g->build_mode == BuildModeDebug, is_small, + g->enable_time_report)) { zig_panic("unable to write assembly file %s: %s", buf_ptr(output_path), err_msg); } @@ -6417,7 +6419,8 @@ static void zig_llvm_emit_output(CodeGen *g) { case EmitFileTypeLLVMIr: if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), - ZigLLVM_EmitLLVMIr, &err_msg, g->build_mode == BuildModeDebug, is_small)) + ZigLLVM_EmitLLVMIr, &err_msg, g->build_mode == BuildModeDebug, is_small, + g->enable_time_report)) { zig_panic("unable to write llvm-ir file %s: %s", buf_ptr(output_path), err_msg); } diff --git a/src/main.cpp b/src/main.cpp index f18dd949b0..fdc34a83ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ static int usage(const char *arg0) { " --cache [auto|off|on] build to the global cache and print output path to stdout\n" " --color [auto|off|on] enable or disable colored error messages\n" " --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n" - " --enable-timing-info print timing diagnostics\n" + " -ftime-report print timing diagnostics\n" " --libc-include-dir [path] directory where libc stdlib.h resides\n" " --name [name] override output name\n" " --output [file] override destination path\n" @@ -402,6 +402,7 @@ int main(int argc, char **argv) { os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path); CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf); + g->enable_time_report = timing_info; buf_init_from_str(&g->cache_dir, cache_dir); codegen_set_out_name(g, buf_create_from_str("build")); @@ -533,7 +534,7 @@ int main(int argc, char **argv) { no_rosegment_workaround = true; } else if (strcmp(arg, "--each-lib-rpath") == 0) { each_lib_rpath = true; - } else if (strcmp(arg, "--enable-timing-info") == 0) { + } else if (strcmp(arg, "-ftime-report") == 0) { timing_info = true; } else if (strcmp(arg, "--test-cmd-bin") == 0) { test_exec_args.append(nullptr); @@ -828,6 +829,7 @@ int main(int argc, char **argv) { Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); + g->enable_time_report = timing_info; buf_init_from_str(&g->cache_dir, cache_dir); codegen_set_out_name(g, buf_out_name); codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index a43d2d182c..61287f620c 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -30,6 +30,7 @@ #include <llvm/PassRegistry.h> #include <llvm/Support/FileSystem.h> #include <llvm/Support/TargetParser.h> +#include <llvm/Support/Timer.h> #include <llvm/Support/raw_ostream.h> #include <llvm/Target/TargetMachine.h> #include <llvm/Transforms/Coroutines.h> @@ -81,8 +82,11 @@ static const bool assertions_on = false; #endif bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, - const char *filename, ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, bool is_small) + const char *filename, ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, + bool is_small, bool time_report) { + TimePassesIsEnabled = time_report; + std::error_code EC; raw_fd_ostream dest(filename, EC, sys::fs::F_None); if (EC) { @@ -182,6 +186,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM } } + if (time_report) { + TimerGroup::printAll(errs()); + } return false; } diff --git a/src/zig_llvm.h b/src/zig_llvm.h index 63d69bd23e..5cdc6cc041 100644 --- a/src/zig_llvm.h +++ b/src/zig_llvm.h @@ -55,7 +55,8 @@ enum ZigLLVM_EmitOutputType { }; ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, - const char *filename, enum ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, bool is_small); + const char *filename, enum ZigLLVM_EmitOutputType output_type, char **error_message, bool is_debug, + bool is_small, bool time_report); ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref); |
