[clang] [llvm] [Driver][DirectX] Add `/Qembed_debug` and `/Fd` flags (PR #204166)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 18 12:48:14 PDT 2026


================
@@ -3854,6 +3854,25 @@ static void RenderHLSLOptions(const Driver &D, const ArgList &Args,
   }
   if (Arg *A = Args.getLastArg(options::OPT_dxc_Zsb))
     A->claim(); // /Zsb is the default behavior, no need to forward it to llc.
+  bool Zi = Args.hasArg(options::OPT_g_Flag);
+  bool Qembed_debug = Args.hasArg(options::OPT_dxc_Qembed_debug);
+  Arg *Fd = Args.getLastArg(options::OPT_dxc_Fd);
+  if (Zi && !Fd && !Qembed_debug) {
+    D.Diag(diag::warn_drv_dxc_no_output_for_debug);
+    Qembed_debug = true;
+  }
+  if (Qembed_debug && !Zi)
+    D.Diag(diag::err_drv_no_debug_info_for_embed_debug);
+  if (Fd && !Zi)
+    D.Diag(diag::err_drv_no_debug_info_for_Fd);
+  if (Qembed_debug) {
+    CmdArgs.push_back("-mllvm");
+    CmdArgs.push_back("--dx-embed-debug");
+  }
+  if (Fd) {
+    CmdArgs.push_back("-mllvm");
+    CmdArgs.push_back(Args.MakeArgString("--dx-Fd=" + Twine(Fd->getValue())));
+  }
----------------
bogner wrote:

Passing this information along via mutually exclusive `cl::opt`s feels pretty awkward here. Would it be a better design to pass this information via `TargetOptions`? I think we could have a single option that way, where If a path is provided it provides the file to write to, if not it implies embedded. I imagine this is more like it would be implemented if we were doing this for `cl` compatibility generally, and probably maps better to whatever we end up doing for SPIR-V here.

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


More information about the cfe-commits mailing list