[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

Mats Petersson via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 04:09:40 PDT 2024


================
@@ -21,4 +22,14 @@ CodeGenOptions::CodeGenOptions() {
 #include "flang/Frontend/CodeGenOptions.def"
 }
 
+std::optional<llvm::CodeModel::Model> getCodeModel(llvm::StringRef string) {
+  return llvm::StringSwitch<std::optional<llvm::CodeModel::Model>>(string)
+      .Case("tiny", llvm::CodeModel::Model::Tiny)
+      .Case("small", llvm::CodeModel::Model::Small)
+      .Case("kernel", llvm::CodeModel::Model::Kernel)
+      .Case("medium", llvm::CodeModel::Model::Medium)
+      .Case("large", llvm::CodeModel::Model::Large)
+      .Default(std::nullopt);
----------------
Leporacanthicus wrote:

Yes, as do we. Just not in this piece of code, it happens when we're parsing arguments. We call this function twice, only checking in the first place. Approximately line 400 of flang/lib/Frontend/CompilerInvocation.cpp 
There are tests in flang/test/Driver/mcmodel.f90 for generating an error.

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


More information about the cfe-commits mailing list