Skip to content

Commit 9e6b46a

Browse files
[flang] Implement -mcmodel flag (#95411)
This patch implements the -mcmodel flag from clang, allowing the Code Model to be changed for the LLVM module. The same set of mcmodel flags are accepted as in clang and the same Code Model attributes are added to the LLVM module for those flags. Also add `-mlarge-data-threshold` for x86-64, which is automatically set by the shared command-line code (see below). This is also added as an attribute into the LLVM module and on the target machine. A function is created for `addMCModel` that is copied out of clang's argument handling so that it can be shared with flang. --------- Co-authored-by: Mats Petersson <[email protected]>
1 parent 845dee3 commit 9e6b46a

File tree

14 files changed

+257
-78
lines changed

14 files changed

+257
-78
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,10 +4612,10 @@ def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group<m_Group>,
46124612
NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", "IAD_Intel"]>,
46134613
MarshallingInfoEnum<CodeGenOpts<"InlineAsmDialect">, "IAD_ATT">;
46144614
def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>,
4615-
Visibility<[ClangOption, CC1Option]>,
4615+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
46164616
MarshallingInfoString<TargetOpts<"CodeModel">, [{"default"}]>;
46174617
def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, Group<m_Group>,
4618-
Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>,
4618+
Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option,FlangOption, FC1Option]>,
46194619
MarshallingInfoInt<TargetOpts<"LargeDataThreshold">, "0">;
46204620
def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>,
46214621
Visibility<[ClangOption, CC1Option]>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5909,81 +5909,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
59095909

59105910
TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
59115911

5912-
if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
5913-
StringRef CM = A->getValue();
5914-
bool Ok = false;
5915-
if (Triple.isOSAIX() && CM == "medium")
5916-
CM = "large";
5917-
if (Triple.isAArch64(64)) {
5918-
Ok = CM == "tiny" || CM == "small" || CM == "large";
5919-
if (CM == "large" && !Triple.isOSBinFormatMachO() &&
5920-
RelocationModel != llvm::Reloc::Static)
5921-
D.Diag(diag::err_drv_argument_only_allowed_with)
5922-
<< A->getAsString(Args) << "-fno-pic";
5923-
} else if (Triple.isLoongArch()) {
5924-
if (CM == "extreme" &&
5925-
Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
5926-
D.Diag(diag::err_drv_argument_not_allowed_with)
5927-
<< A->getAsString(Args) << "-fplt";
5928-
Ok = CM == "normal" || CM == "medium" || CM == "extreme";
5929-
// Convert to LLVM recognizable names.
5930-
if (Ok)
5931-
CM = llvm::StringSwitch<StringRef>(CM)
5932-
.Case("normal", "small")
5933-
.Case("extreme", "large")
5934-
.Default(CM);
5935-
} else if (Triple.isPPC64() || Triple.isOSAIX()) {
5936-
Ok = CM == "small" || CM == "medium" || CM == "large";
5937-
} else if (Triple.isRISCV()) {
5938-
if (CM == "medlow")
5939-
CM = "small";
5940-
else if (CM == "medany")
5941-
CM = "medium";
5942-
Ok = CM == "small" || CM == "medium";
5943-
} else if (Triple.getArch() == llvm::Triple::x86_64) {
5944-
Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
5945-
CM);
5946-
} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
5947-
// NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
5948-
// whatever works for the host.
5949-
Ok = true;
5950-
} else if (Triple.isSPARC64()) {
5951-
if (CM == "medlow")
5952-
CM = "small";
5953-
else if (CM == "medmid")
5954-
CM = "medium";
5955-
else if (CM == "medany")
5956-
CM = "large";
5957-
Ok = CM == "small" || CM == "medium" || CM == "large";
5958-
}
5959-
if (Ok) {
5960-
CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
5961-
} else {
5962-
D.Diag(diag::err_drv_unsupported_option_argument_for_target)
5963-
<< A->getSpelling() << CM << TripleStr;
5964-
}
5965-
}
5966-
5967-
if (Triple.getArch() == llvm::Triple::x86_64) {
5968-
bool IsMediumCM = false;
5969-
bool IsLargeCM = false;
5970-
if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
5971-
IsMediumCM = StringRef(A->getValue()) == "medium";
5972-
IsLargeCM = StringRef(A->getValue()) == "large";
5973-
}
5974-
if (Arg *A = Args.getLastArg(options::OPT_mlarge_data_threshold_EQ)) {
5975-
if (!IsMediumCM && !IsLargeCM) {
5976-
D.Diag(diag::warn_drv_large_data_threshold_invalid_code_model)
5977-
<< A->getOption().getRenderName();
5978-
} else {
5979-
A->render(Args, CmdArgs);
5980-
}
5981-
} else if (IsMediumCM) {
5982-
CmdArgs.push_back("-mlarge-data-threshold=65536");
5983-
} else if (IsLargeCM) {
5984-
CmdArgs.push_back("-mlarge-data-threshold=0");
5985-
}
5986-
}
5912+
addMCModel(D, Args, Triple, RelocationModel, CmdArgs);
59875913

59885914
if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {
59895915
StringRef Value = A->getValue();

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,3 +2825,84 @@ void tools::addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs,
28252825
CmdArgs.push_back(
28262826
TCArgs.MakeArgString(Twine("-compression-level=") + Arg->getValue()));
28272827
}
2828+
2829+
void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,
2830+
const llvm::Triple &Triple,
2831+
const llvm::Reloc::Model &RelocationModel,
2832+
llvm::opt::ArgStringList &CmdArgs) {
2833+
if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
2834+
StringRef CM = A->getValue();
2835+
bool Ok = false;
2836+
if (Triple.isOSAIX() && CM == "medium")
2837+
CM = "large";
2838+
if (Triple.isAArch64(64)) {
2839+
Ok = CM == "tiny" || CM == "small" || CM == "large";
2840+
if (CM == "large" && !Triple.isOSBinFormatMachO() &&
2841+
RelocationModel != llvm::Reloc::Static)
2842+
D.Diag(diag::err_drv_argument_only_allowed_with)
2843+
<< A->getAsString(Args) << "-fno-pic";
2844+
} else if (Triple.isLoongArch()) {
2845+
if (CM == "extreme" &&
2846+
Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
2847+
D.Diag(diag::err_drv_argument_not_allowed_with)
2848+
<< A->getAsString(Args) << "-fplt";
2849+
Ok = CM == "normal" || CM == "medium" || CM == "extreme";
2850+
// Convert to LLVM recognizable names.
2851+
if (Ok)
2852+
CM = llvm::StringSwitch<StringRef>(CM)
2853+
.Case("normal", "small")
2854+
.Case("extreme", "large")
2855+
.Default(CM);
2856+
} else if (Triple.isPPC64() || Triple.isOSAIX()) {
2857+
Ok = CM == "small" || CM == "medium" || CM == "large";
2858+
} else if (Triple.isRISCV()) {
2859+
if (CM == "medlow")
2860+
CM = "small";
2861+
else if (CM == "medany")
2862+
CM = "medium";
2863+
Ok = CM == "small" || CM == "medium";
2864+
} else if (Triple.getArch() == llvm::Triple::x86_64) {
2865+
Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
2866+
CM);
2867+
} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
2868+
// NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
2869+
// whatever works for the host.
2870+
Ok = true;
2871+
} else if (Triple.isSPARC64()) {
2872+
if (CM == "medlow")
2873+
CM = "small";
2874+
else if (CM == "medmid")
2875+
CM = "medium";
2876+
else if (CM == "medany")
2877+
CM = "large";
2878+
Ok = CM == "small" || CM == "medium" || CM == "large";
2879+
}
2880+
if (Ok) {
2881+
CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
2882+
} else {
2883+
D.Diag(diag::err_drv_unsupported_option_argument_for_target)
2884+
<< A->getSpelling() << CM << Triple.getTriple();
2885+
}
2886+
}
2887+
2888+
if (Triple.getArch() == llvm::Triple::x86_64) {
2889+
bool IsMediumCM = false;
2890+
bool IsLargeCM = false;
2891+
if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
2892+
IsMediumCM = StringRef(A->getValue()) == "medium";
2893+
IsLargeCM = StringRef(A->getValue()) == "large";
2894+
}
2895+
if (Arg *A = Args.getLastArg(options::OPT_mlarge_data_threshold_EQ)) {
2896+
if (!IsMediumCM && !IsLargeCM) {
2897+
D.Diag(diag::warn_drv_large_data_threshold_invalid_code_model)
2898+
<< A->getOption().getRenderName();
2899+
} else {
2900+
A->render(Args, CmdArgs);
2901+
}
2902+
} else if (IsMediumCM) {
2903+
CmdArgs.push_back("-mlarge-data-threshold=65536");
2904+
} else if (IsLargeCM) {
2905+
CmdArgs.push_back("-mlarge-data-threshold=0");
2906+
}
2907+
}
2908+
}

clang/lib/Driver/ToolChains/CommonArgs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC,
223223
const llvm::Triple &Triple);
224224
void addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs,
225225
llvm::opt::ArgStringList &CmdArgs);
226+
void addMCModel(const Driver &D, const llvm::opt::ArgList &Args,
227+
const llvm::Triple &Triple,
228+
const llvm::Reloc::Model &RelocationModel,
229+
llvm::opt::ArgStringList &CmdArgs);
226230

227231
} // end namespace tools
228232
} // end namespace driver

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,11 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
735735
// Add target args, features, etc.
736736
addTargetOptions(Args, CmdArgs);
737737

738+
llvm::Reloc::Model RelocationModel =
739+
std::get<0>(ParsePICArgs(getToolChain(), Args));
740+
// Add MCModel information
741+
addMCModel(D, Args, Triple, RelocationModel, CmdArgs);
742+
738743
// Add Codegen options
739744
addCodegenOptions(Args, CmdArgs);
740745

flang/include/flang/Frontend/CodeGenOptions.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
133133
/// transformation.
134134
OptRemark OptimizationRemarkAnalysis;
135135

136+
/// The code model to use (-mcmodel).
137+
std::string CodeModel;
138+
139+
/// The code model-specific large data threshold to use
140+
/// (-mlarge-data-threshold).
141+
uint64_t LargeDataThreshold;
142+
136143
// Define accessors/mutators for code generation options of enumeration type.
137144
#define CODEGENOPT(Name, Bits, Default)
138145
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
@@ -143,6 +150,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
143150
CodeGenOptions();
144151
};
145152

153+
std::optional<llvm::CodeModel::Model> getCodeModel(llvm::StringRef string);
154+
146155
} // end namespace Fortran::frontend
147156

148157
#endif // FORTRAN_FRONTEND_CODEGENOPTIONS_H

flang/lib/Frontend/CodeGenOptions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "flang/Frontend/CodeGenOptions.h"
14+
#include <optional>
1415
#include <string.h>
1516

1617
namespace Fortran::frontend {
@@ -21,4 +22,14 @@ CodeGenOptions::CodeGenOptions() {
2122
#include "flang/Frontend/CodeGenOptions.def"
2223
}
2324

25+
std::optional<llvm::CodeModel::Model> getCodeModel(llvm::StringRef string) {
26+
return llvm::StringSwitch<std::optional<llvm::CodeModel::Model>>(string)
27+
.Case("tiny", llvm::CodeModel::Model::Tiny)
28+
.Case("small", llvm::CodeModel::Model::Small)
29+
.Case("kernel", llvm::CodeModel::Model::Kernel)
30+
.Case("medium", llvm::CodeModel::Model::Medium)
31+
.Case("large", llvm::CodeModel::Model::Large)
32+
.Default(std::nullopt);
33+
}
34+
2435
} // end namespace Fortran::frontend

flang/lib/Frontend/CompilerInstance.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,19 @@ bool CompilerInstance::setUpTargetMachine() {
321321
assert(OptLevelOrNone && "Invalid optimization level!");
322322
llvm::CodeGenOptLevel OptLevel = *OptLevelOrNone;
323323
std::string featuresStr = getTargetFeatures();
324+
std::optional<llvm::CodeModel::Model> cm = getCodeModel(CGOpts.CodeModel);
324325
targetMachine.reset(theTarget->createTargetMachine(
325326
theTriple, /*CPU=*/targetOpts.cpu,
326327
/*Features=*/featuresStr, llvm::TargetOptions(),
327328
/*Reloc::Model=*/CGOpts.getRelocationModel(),
328-
/*CodeModel::Model=*/std::nullopt, OptLevel));
329+
/*CodeModel::Model=*/cm, OptLevel));
329330
assert(targetMachine && "Failed to create TargetMachine");
331+
if (cm.has_value()) {
332+
const llvm::Triple triple(theTriple);
333+
if ((cm == llvm::CodeModel::Medium || cm == llvm::CodeModel::Large) &&
334+
triple.getArch() == llvm::Triple::x86_64) {
335+
targetMachine->setLargeDataThreshold(CGOpts.LargeDataThreshold);
336+
}
337+
}
330338
return true;
331339
}

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/Option/Arg.h"
3333
#include "llvm/Option/ArgList.h"
3434
#include "llvm/Option/OptTable.h"
35+
#include "llvm/Support/CodeGen.h"
3536
#include "llvm/Support/FileSystem.h"
3637
#include "llvm/Support/FileUtilities.h"
3738
#include "llvm/Support/Path.h"
@@ -386,6 +387,29 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
386387
opts.IsPIE = 1;
387388
}
388389

390+
// -mcmodel option.
391+
if (const llvm::opt::Arg *a =
392+
args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) {
393+
llvm::StringRef modelName = a->getValue();
394+
std::optional<llvm::CodeModel::Model> codeModel = getCodeModel(modelName);
395+
396+
if (codeModel.has_value())
397+
opts.CodeModel = modelName;
398+
else
399+
diags.Report(clang::diag::err_drv_invalid_value)
400+
<< a->getAsString(args) << modelName;
401+
}
402+
403+
if (const llvm::opt::Arg *arg = args.getLastArg(
404+
clang::driver::options::OPT_mlarge_data_threshold_EQ)) {
405+
uint64_t LDT;
406+
if (llvm::StringRef(arg->getValue()).getAsInteger(/*Radix=*/10, LDT)) {
407+
diags.Report(clang::diag::err_drv_invalid_value)
408+
<< arg->getSpelling() << arg->getValue();
409+
}
410+
opts.LargeDataThreshold = LDT;
411+
}
412+
389413
// This option is compatible with -f[no-]underscoring in gfortran.
390414
if (args.hasFlag(clang::driver::options::OPT_fno_underscoring,
391415
clang::driver::options::OPT_funderscoring, false)) {

flang/lib/Frontend/FrontendActions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,17 @@ void CodeGenAction::generateLLVMIR() {
866866
llvmModule->setPIELevel(
867867
static_cast<llvm::PIELevel::Level>(opts.PICLevel));
868868
}
869+
870+
// Set mcmodel level LLVM module flags
871+
std::optional<llvm::CodeModel::Model> cm = getCodeModel(opts.CodeModel);
872+
if (cm.has_value()) {
873+
const llvm::Triple triple(ci.getInvocation().getTargetOpts().triple);
874+
llvmModule->setCodeModel(*cm);
875+
if ((cm == llvm::CodeModel::Medium || cm == llvm::CodeModel::Large) &&
876+
triple.getArch() == llvm::Triple::x86_64) {
877+
llvmModule->setLargeDataThreshold(opts.LargeDataThreshold);
878+
}
879+
}
869880
}
870881

871882
static std::unique_ptr<llvm::raw_pwrite_stream>
@@ -1280,6 +1291,7 @@ void CodeGenAction::executeAction() {
12801291
// and the command-line target option if specified, or the default if not
12811292
// given on the command-line).
12821293
llvm::TargetMachine &targetMachine = ci.getTargetMachine();
1294+
12831295
const std::string &theTriple = targetMachine.getTargetTriple().str();
12841296

12851297
if (llvmModule->getTargetTriple() != theTriple) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
! RUN: %flang -### -c --target=x86_64 -mcmodel=large -mlarge-data-threshold=32768 %s 2>&1 | FileCheck %s
2+
! RUN: %flang -### -c --target=x86_64 -mcmodel=large -mlarge-data-threshold=59000 %s 2>&1 | FileCheck %s --check-prefix=CHECK-59000
3+
! RUN: %flang -### -c --target=x86_64 -mcmodel=large -mlarge-data-threshold=1048576 %s 2>&1 | FileCheck %s --check-prefix=CHECK-1M
4+
! RUN: not %flang -c --target=x86_64 -mcmodel=large -mlarge-data-threshold=nonsense %s 2>&1 | FileCheck %s --check-prefix=INVALID
5+
! RUN: %flang -### -c --target=x86_64 -mlarge-data-threshold=32768 %s 2>&1 | FileCheck %s --check-prefix=NO-MCMODEL
6+
! RUN: %flang -### -c --target=x86_64 -mcmodel=small -mlarge-data-threshold=32768 %s 2>&1 | FileCheck %s --check-prefix=NO-MCMODEL
7+
! RUN: not %flang -### -c --target=aarch64 -mcmodel=small -mlarge-data-threshold=32768 %s 2>&1 | FileCheck %s --check-prefix=NOT-SUPPORTED
8+
9+
10+
! CHECK: "{{.*}}flang-new" "-fc1"
11+
! CHECK-SAME: "-mlarge-data-threshold=32768"
12+
! CHECK-59000: "{{.*}}flang-new" "-fc1"
13+
! CHECK-59000-SAME: "-mlarge-data-threshold=59000"
14+
! CHECK-1M: "{{.*}}flang-new" "-fc1"
15+
! CHECK-1M-SAME: "-mlarge-data-threshold=1048576"
16+
! NO-MCMODEL: 'mlarge-data-threshold=' only applies to medium and large code models
17+
! INVALID: error: invalid value 'nonsense' in '-mlarge-data-threshold='
18+
! NOT-SUPPORTED: error: unsupported option '-mlarge-data-threshold=' for target 'aarch64'

flang/test/Driver/mcmodel.f90

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
! RUN: not %flang -### -c --target=i686 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
2+
! RUN: %flang --target=x86_64 -### -c -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=TINY %s
3+
! RUN: %flang --target=x86_64 -### -c -mcmodel=small %s 2>&1 | FileCheck --check-prefix=SMALL %s
4+
! RUN: %flang --target=x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=KERNEL %s
5+
! RUN: %flang --target=x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
6+
! RUN: %flang --target=x86_64 -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
7+
! RUN: not %flang -### -c --target=powerpc-linux-gnu -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
8+
! RUN: %flang --target=powerpc-unknown-aix -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=SMALL %s
9+
! RUN: %flang --target=powerpc-unknown-aix -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
10+
! RUN: %flang --target=powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log
11+
! RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
12+
! RUN: not %flang -### -c -mcmodel=lager %s 2>&1 | FileCheck --check-prefix=INVALID %s
13+
! RUN: %flang --target=aarch64 -### -S -mcmodel=large -fno-pic %s 2>&1 | FileCheck --check-prefix=LARGE %s
14+
! RUN: %flang --target=aarch64-apple-macosx -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
15+
! RUN: not %flang --target=aarch64 -### -S -mcmodel=large -fpic %s 2>&1 | FileCheck --check-prefix=AARCH64-PIC-LARGE %s
16+
! RUN: not %flang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
17+
! RUN: not %flang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=ERR-KERNEL %s
18+
! RUN: not %flang --target=aarch64_32-linux -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=ERR-AARCH64_32 %s
19+
! RUN: %flang --target=loongarch64 -### -S -mcmodel=normal %s 2>&1 | FileCheck --check-prefix=SMALL %s
20+
! RUN: %flang --target=loongarch64 -### -S -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
21+
! RUN: %flang --target=loongarch64 -### -S -mcmodel=extreme %s 2>&1 | FileCheck --check-prefix=LARGE %s
22+
! RUN: not %flang --target=loongarch64 -### -S -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=ERR-TINY %s
23+
! RUN: not %flang --target=loongarch64 -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=ERR-SMALL %s
24+
! RUN: not %flang --target=loongarch64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=ERR-KERNEL %s
25+
! RUN: not %flang --target=loongarch64 -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=ERR-LARGE %s
26+
27+
! TINY: "-mcmodel=tiny"
28+
! SMALL: "-mcmodel=small"
29+
! KERNEL: "-mcmodel=kernel"
30+
! MEDIUM: "-mcmodel=medium"
31+
! LARGE: "-mcmodel=large"
32+
! AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
33+
34+
! INVALID: error: unsupported argument 'lager' to option '-mcmodel=' for target '{{.*}}'
35+
36+
! ERR-TINY: error: unsupported argument 'tiny' to option '-mcmodel=' for target '{{.*}}'
37+
! ERR-SMALL: error: unsupported argument 'small' to option '-mcmodel=' for target '{{.*}}'
38+
! ERR-MEDIUM: error: unsupported argument 'medium' to option '-mcmodel=' for target '{{.*}}'
39+
! ERR-KERNEL: error: unsupported argument 'kernel' to option '-mcmodel=' for target '{{.*}}'
40+
! ERR-LARGE: error: unsupported argument 'large' to option '-mcmodel=' for target '{{.*}}'
41+
42+
! AARCH64-PIC-LARGE: error: invalid argument '-mcmodel=large' only allowed with '-fno-pic'
43+
! ERR-AARCH64_32: error: unsupported argument 'small' to option '-mcmodel=' for target 'aarch64_32-unknown-linux'
44+

0 commit comments

Comments
 (0)