diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h index c9c41a4e0ef3..810ae7b9a9c6 100644 --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -86,7 +86,7 @@ struct Configuration { uint32_t headerPad; uint32_t dylibCompatibilityVersion = 0; uint32_t dylibCurrentVersion = 0; - uint32_t timeTraceGranularity = 0; + uint32_t timeTraceGranularity = 500; std::string progName; llvm::StringRef installName; llvm::StringRef mapFile; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 86ae732fdc76..d262ad568539 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -998,13 +998,15 @@ bool macho::link(ArrayRef argsArr, bool canExitEarly, config->progName = argsArr[0]; config->timeTraceEnabled = args.hasArg(OPT_time_trace); + config->timeTraceGranularity = + args::getInteger(args, OPT_time_trace_granularity_eq, 500); // Initialize time trace profiler. if (config->timeTraceEnabled) timeTraceProfilerInitialize(config->timeTraceGranularity, config->progName); { - TimeTraceScope timeScope("Link", StringRef("ExecuteLinker")); + TimeTraceScope timeScope("ExecuteLinker"); initLLVM(); // must be run before any call to addFile() createFiles(args); diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td index c6e61219f345..da2c53e2e492 100644 --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -39,9 +39,9 @@ def no_lto_legacy_pass_manager : Flag<["--"], "no-lto-legacy-pass-manager">, HelpText<"Use the new pass manager in LLVM">, Group; def time_trace: Flag<["--"], "time-trace">, HelpText<"Record time trace">; -def time_trace_granularity: Flag<["--"], "time-trace-granularity">, +def time_trace_granularity_eq: Joined<["--"], "time-trace-granularity=">, HelpText<"Minimum time granularity (in microseconds) traced by time profiler">; -def time_trace_file_eq: Flag<["--"], "time-trace-file=">, HelpText<"Specify time trace output file">; +def time_trace_file_eq: Joined<["--"], "time-trace-file=">, HelpText<"Specify time trace output file">; // This is a complete Options.td compiled from Apple's ld(1) manpage // dated 2018-03-07 and cross checked with ld64 source code in repo diff --git a/lld/test/MachO/time-trace.s b/lld/test/MachO/time-trace.s index cb31dd706f9d..b203055a020a 100644 --- a/lld/test/MachO/time-trace.s +++ b/lld/test/MachO/time-trace.s @@ -1,20 +1,20 @@ # REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o # Test implicit trace file name -# RUN: ld.lld --time-trace --time-trace-granularity=0 -o %t1.macho %t.o +# RUN: %lld --time-trace --time-trace-granularity=0 -o %t1.macho %t.o # RUN: cat %t1.macho.time-trace \ # RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ # RUN: | FileCheck %s # Test specified trace file name -# RUN: ld.lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o +# RUN: %lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o # RUN: cat %t2.json \ # RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ # RUN: | FileCheck %s # Test trace requested to stdout -# RUN: ld.lld --time-trace --time-trace-file=- --time-trace-granularity=0 -o %t3.macho %t.o \ +# RUN: %lld --time-trace --time-trace-file=- --time-trace-granularity=0 -o %t3.macho %t.o \ # RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ # RUN: | FileCheck %s @@ -33,10 +33,10 @@ # CHECK: "name": "ExecuteLinker" # Check process_name entry field -# CHECK: "name": "ld.lld{{(.exe)?}}" +# CHECK: "name": "ld64.lld{{(.exe)?}}" # CHECK: "name": "process_name" # CHECK: "name": "thread_name" -.globl _start -_start: +.globl _main +_main: ret