[lld-macho] Fix parsing of --time-trace-{granularity,file}

Summary: We needed to use `Joined` instead of `Flag`. This wasn't caught
because the relevant test that was copied from LLD-ELF was still
invoking LLD-ELF instead of LLD-MachO...

Differential Revision: https://reviews.llvm.org/D99313

GitOrigin-RevId: 94e369400e5380e10b49387fd321ff1564fb0207
diff --git a/MachO/Config.h b/MachO/Config.h
index c9c41a4..810ae7b 100644
--- a/MachO/Config.h
+++ b/MachO/Config.h
@@ -86,7 +86,7 @@
   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/MachO/Driver.cpp b/MachO/Driver.cpp
index 86ae732..d262ad5 100644
--- a/MachO/Driver.cpp
+++ b/MachO/Driver.cpp
@@ -998,13 +998,15 @@
   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/MachO/Options.td b/MachO/Options.td
index c6e6121..da2c53e 100644
--- a/MachO/Options.td
+++ b/MachO/Options.td
@@ -39,9 +39,9 @@
     HelpText<"Use the new pass manager in LLVM">,
     Group<grp_lld>;
 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/test/MachO/time-trace.s b/test/MachO/time-trace.s
index cb31dd7..b203055 100644
--- a/test/MachO/time-trace.s
+++ b/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