[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 8 07:54:28 PDT 2024


================
@@ -527,9 +527,11 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) {
 
   // Forward all of the `--offload-opt` and similar options to the device.
   if (linkerSupportsLTO(Args)) {
-    for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
+    for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) {
+      CmdArgs.push_back(Args.MakeArgString("-Xlinker"));
----------------
jhuber6 wrote:

```suggestion
      CmdArgs.append({"-Xlinker", Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});
```
I like having these joined arguments in a single command, also you don't need `MakeArgString` for a C string since it already has permanent storage.

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


More information about the cfe-commits mailing list