authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-11 22:46:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-11 22:46:22-04:00
log014cc60a72ac2d64935bf424459b5fa13e281ed9
tree7f8c43d42297bb52e39366bb45084f7ee6662ae3
parentee263a15cc8fb52c2ac6053a29168fb15089839b
signaturelock-open Commit is signed but in an unrecognized format.

rename --enable-timing-info to -ftime-report to match clang

and have it print llvm's internal timing info

5 files changed, 21 insertions(+), 7 deletions(-)

src/all_types.hpp+1
......@@ -1727,6 +1727,7 @@ struct CodeGen {
17271727 bool error_during_imports;
17281728 bool generate_error_name_table;
17291729 bool enable_cache;
1730 bool enable_time_report;
17301731
17311732 //////////////////////////// Participates in Input Parameter Cache Hash
17321733 ZigList<LinkLib *> link_libs_list;
src/codegen.cpp+6-3
......@@ -6398,7 +6398,8 @@ static void zig_llvm_emit_output(CodeGen *g) {
63986398 switch (g->emit_file_type) {
63996399 case EmitFileTypeBinary:
64006400 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))
64026403 {
64036404 zig_panic("unable to write object file %s: %s", buf_ptr(output_path), err_msg);
64046405 }
......@@ -6408,7 +6409,8 @@ static void zig_llvm_emit_output(CodeGen *g) {
64086409
64096410 case EmitFileTypeAssembly:
64106411 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))
64126414 {
64136415 zig_panic("unable to write assembly file %s: %s", buf_ptr(output_path), err_msg);
64146416 }
......@@ -6417,7 +6419,8 @@ static void zig_llvm_emit_output(CodeGen *g) {
64176419
64186420 case EmitFileTypeLLVMIr:
64196421 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))
64216424 {
64226425 zig_panic("unable to write llvm-ir file %s: %s", buf_ptr(output_path), err_msg);
64236426 }
src/main.cpp+4-2
......@@ -37,7 +37,7 @@ static int usage(const char *arg0) {
3737 " --cache [auto|off|on] build to the global cache and print output path to stdout\n"
3838 " --color [auto|off|on] enable or disable colored error messages\n"
3939 " --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"
4141 " --libc-include-dir [path] directory where libc stdlib.h resides\n"
4242 " --name [name] override output name\n"
4343 " --output [file] override destination path\n"
......@@ -402,6 +402,7 @@ int main(int argc, char **argv) {
402402 os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path);
403403
404404 CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf);
405 g->enable_time_report = timing_info;
405406 buf_init_from_str(&g->cache_dir, cache_dir);
406407 codegen_set_out_name(g, buf_create_from_str("build"));
407408
......@@ -533,7 +534,7 @@ int main(int argc, char **argv) {
533534 no_rosegment_workaround = true;
534535 } else if (strcmp(arg, "--each-lib-rpath") == 0) {
535536 each_lib_rpath = true;
536 } else if (strcmp(arg, "--enable-timing-info") == 0) {
537 } else if (strcmp(arg, "-ftime-report") == 0) {
537538 timing_info = true;
538539 } else if (strcmp(arg, "--test-cmd-bin") == 0) {
539540 test_exec_args.append(nullptr);
......@@ -828,6 +829,7 @@ int main(int argc, char **argv) {
828829 Buf *zig_lib_dir_buf = resolve_zig_lib_dir();
829830
830831 CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf);
832 g->enable_time_report = timing_info;
831833 buf_init_from_str(&g->cache_dir, cache_dir);
832834 codegen_set_out_name(g, buf_out_name);
833835 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
src/zig_llvm.cpp+8-1
......@@ -30,6 +30,7 @@
3030#include <llvm/PassRegistry.h>
3131#include <llvm/Support/FileSystem.h>
3232#include <llvm/Support/TargetParser.h>
33#include <llvm/Support/Timer.h>
3334#include <llvm/Support/raw_ostream.h>
3435#include <llvm/Target/TargetMachine.h>
3536#include <llvm/Transforms/Coroutines.h>
......@@ -81,8 +82,11 @@ static const bool assertions_on = false;
8182#endif
8283
8384bool 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)
8587{
88 TimePassesIsEnabled = time_report;
89
8690 std::error_code EC;
8791 raw_fd_ostream dest(filename, EC, sys::fs::F_None);
8892 if (EC) {
......@@ -182,6 +186,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
182186 }
183187 }
184188
189 if (time_report) {
190 TimerGroup::printAll(errs());
191 }
185192 return false;
186193}
187194
src/zig_llvm.h+2-1
......@@ -55,7 +55,8 @@ enum ZigLLVM_EmitOutputType {
5555};
5656
5757ZIG_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);
5960
6061ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref);
6162