[clang] [Driver] Enable -ftime-trace for CUDA/HIP device compilation (PR #179701)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 19 07:19:12 PST 2026


================
@@ -5858,22 +5858,67 @@ static void handleTimeTrace(Compilation &C, const ArgList &Args,
       Args.getLastArg(options::OPT_ftime_trace, options::OPT_ftime_trace_EQ);
   if (!A)
     return;
+
+  std::string OffloadingPrefix;
+  if (JA->getOffloadingDeviceKind() != Action::OFK_None) {
+    const ToolChain *TC = JA->getOffloadingToolChain();
+    OffloadingPrefix = Action::GetOffloadingFileNamePrefix(
+        JA->getOffloadingDeviceKind(),
+        TC ? TC->getTriple().normalize() : "",
+        /*CreatePrefixForHost=*/false);
+    if (const char *Arch = JA->getOffloadingArch()) {
+      OffloadingPrefix += "-";
+      OffloadingPrefix += Arch;
+    }
+  } else if (JA->getOffloadingHostActiveKinds() != Action::OFK_None &&
+             C.getDriver().isSaveTempsEnabled()) {
+    OffloadingPrefix = Action::GetOffloadingFileNamePrefix(
+        Action::OFK_None,
----------------
jhuber6 wrote:

Why do we pass in OFK_None here if save temps is enabled? I'm also wondering why just calling this is insufficient for our case, since it's supposed to make a valid prefix. I thought that included the arch already.

https://github.com/llvm/llvm-project/pull/179701


More information about the cfe-commits mailing list