[clang] [clang][Driver][RISCV] Honor -m[no-]global-merge for RISC-V (PR #79372)

Jonathon Penix via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 15:51:25 PST 2024


================
@@ -2129,6 +2129,16 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args,
           << A->getSpelling() << Val;
     }
   }
+
+  // Forward the -mglobal-merge option for explicit control over the pass.
+  if (Arg *A = Args.getLastArg(options::OPT_mglobal_merge,
+                               options::OPT_mno_global_merge)) {
+    CmdArgs.push_back("-mllvm");
----------------
jonathonpenix wrote:

I see, thanks!

Just to double check if I did the right thing: I removed the `=true` from the `-mglobal-merge` case but otherwise I left the if/else alone (ex: I'm still passing `-mllvm -riscv-enable-global-merge=false`) so that we can distinguish between the 'unset' (no `-m[no-]global-merge`) and `-mno-global-merge` cases.

I don't think it makes much of a functional difference at the moment since we only check for `EnableGlobalMerge == cl::BOU_TRUE`, but this seemed in line with the decision in https://reviews.llvm.org/D130481 to keep it as boolOrDefault. Please let me know if you had something else in mind!

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


More information about the cfe-commits mailing list