[clang] [Driver] Support -mcmodel= for LoongArch (PR #72514)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 10:43:16 PST 2023


================
@@ -5739,6 +5739,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
       if (CM == "large" && RelocationModel != llvm::Reloc::Static)
         D.Diag(diag::err_drv_argument_only_allowed_with)
             << A->getAsString(Args) << "-fno-pic";
+    } else if (Triple.isLoongArch()) {
+      CM = llvm::StringSwitch<StringRef>(CM)
+               .Case("normal", "small")
+               .Case("extreme", "large")
+               .Default(CM);
+      if (CM == "large" &&
+          Args.hasFlag(options::OPT_fplt, options::OPT_fno_plt, false))
----------------
MaskRay wrote:

`hasFlagNoClaim` is slightly better

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


More information about the cfe-commits mailing list