Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -592,9 +592,10 @@ } if (config->timeTraceEnabled) { - checkError(timeTraceProfilerWrite( - args.getLastArgValue(OPT_time_trace_file_eq).str(), - config->outputFile)); + StringRef traceName; + if (opt::Arg *A = args.getLastArg(OPT_time_trace_file_eq, OPT_trace_to_eq)) + traceName = A->getValue(); + checkError(timeTraceProfilerWrite(traceName.str(), config->outputFile)); timeTraceProfilerCleanup(); } } @@ -1184,7 +1185,7 @@ getOldNewOptions(args, OPT_thinlto_prefix_replace_eq); config->thinLTOModulesToCompile = args::getStrings(args, OPT_thinlto_single_module_eq); - config->timeTraceEnabled = args.hasArg(OPT_time_trace); + config->timeTraceEnabled = args.hasArg(OPT_time_trace, OPT_trace_to_eq); config->timeTraceGranularity = args::getInteger(args, OPT_time_trace_granularity, 500); config->trace = args.hasArg(OPT_trace); Index: lld/ELF/Options.td =================================================================== --- lld/ELF/Options.td +++ lld/ELF/Options.td @@ -410,6 +410,8 @@ def time_trace: FF<"time-trace">, HelpText<"Record time trace">; def time_trace_file_eq: JJ<"time-trace-file=">, HelpText<"Specify time trace output file">; +def trace_to_eq: JJ<"trace-to=">, MetaVarName<"">, + HelpText<"Short for --time-trace --time-trace-file=">; defm time_trace_granularity: EEq<"time-trace-granularity", "Minimum time granularity (in microseconds) traced by time profiler">; Index: lld/MachO/Driver.cpp =================================================================== --- lld/MachO/Driver.cpp +++ lld/MachO/Driver.cpp @@ -1494,8 +1494,7 @@ config->progName = argsArr[0]; - config->timeTraceEnabled = args.hasArg( - OPT_time_trace, OPT_time_trace_granularity_eq, OPT_time_trace_file_eq); + config->timeTraceEnabled = args.hasArg(OPT_time_trace, OPT_trace_to_eq); config->timeTraceGranularity = args::getInteger(args, OPT_time_trace_granularity_eq, 500); @@ -1630,9 +1629,10 @@ } if (config->timeTraceEnabled) { - checkError(timeTraceProfilerWrite( - args.getLastArgValue(OPT_time_trace_file_eq).str(), - config->outputFile)); + StringRef traceName; + if (Arg *A = args.getLastArg(OPT_time_trace_file_eq, OPT_trace_to_eq)) + traceName = A->getValue(); + checkError(timeTraceProfilerWrite(traceName.str(), config->outputFile)); timeTraceProfilerCleanup(); } Index: lld/MachO/Options.td =================================================================== --- lld/MachO/Options.td +++ lld/MachO/Options.td @@ -51,6 +51,10 @@ def time_trace_file_eq: Joined<["--"], "time-trace-file=">, HelpText<"Specify time trace output file">, Group; +def trace_to_eq: Joined<["--"], "trace-to=">, + HelpText<"Short for --time-trace --time-trace-file=">, + MetaVarName<"">, + Group; def deduplicate_literals: Flag<["--"], "deduplicate-literals">, HelpText<"Enable literal deduplication. This is implied by --icf={safe,all}">, Group; Index: lld/test/ELF/time-trace.s =================================================================== --- lld/test/ELF/time-trace.s +++ lld/test/ELF/time-trace.s @@ -9,6 +9,7 @@ # Test specified trace file name # RUN: ld.lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.elf %t.o +# RUN: ld.lld --trace-to=%t2.json --time-trace-granularity=0 -o %t2.elf %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 Index: lld/test/MachO/time-trace.s =================================================================== --- lld/test/MachO/time-trace.s +++ lld/test/MachO/time-trace.s @@ -11,14 +11,15 @@ # 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, also test that `--time-trace` is not needed if the other two are used. -# RUN: %lld --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o +## Test specified trace file name. +# RUN: %lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o +# RUN: %lld --trace-to=%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, also test that `--time-trace` is not needed if the other two are used. -# RUN: %lld --time-trace-file=- --time-trace-granularity=0 -o %t3.macho %t.o \ +## Test trace requested to stdout. +# 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