[RISCV] Allow -mcmodel= to accept large for RV64 (#107817)
This commit is contained in:
@@ -460,6 +460,8 @@ LoongArch Support
|
||||
RISC-V Support
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
- The option ``-mcmodel=large`` for the large code model is supported.
|
||||
|
||||
CUDA/HIP Language Changes
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -2902,11 +2902,16 @@ void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,
|
||||
} else if (Triple.isPPC64() || Triple.isOSAIX()) {
|
||||
Ok = CM == "small" || CM == "medium" || CM == "large";
|
||||
} else if (Triple.isRISCV()) {
|
||||
// Large code model is disallowed to be used with PIC code model.
|
||||
if (CM == "large" && RelocationModel != llvm::Reloc::Static)
|
||||
D.Diag(diag::err_drv_argument_not_allowed_with)
|
||||
<< A->getAsString(Args) << "-fpic";
|
||||
if (CM == "medlow")
|
||||
CM = "small";
|
||||
else if (CM == "medany")
|
||||
CM = "medium";
|
||||
Ok = CM == "small" || CM == "medium";
|
||||
Ok = CM == "small" || CM == "medium" ||
|
||||
(CM == "large" && Triple.isRISCV64());
|
||||
} else if (Triple.getArch() == llvm::Triple::x86_64) {
|
||||
Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
|
||||
CM);
|
||||
|
||||
@@ -10,5 +10,14 @@
|
||||
// RUN: %clang --target=riscv32 -### -c -mcmodel=medany %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
|
||||
// RUN: %clang --target=riscv64 -### -c -mcmodel=medany %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
|
||||
|
||||
// RUN: not %clang --target=riscv32 -### -c -mcmodel=large %s 2>&1 | FileCheck --check-prefix=ERR-LARGE %s
|
||||
// RUN: %clang --target=riscv64 -### -c -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
|
||||
|
||||
// RUN: not %clang --target=riscv64 -### -c -mcmodel=large -fpic %s 2>&1 | FileCheck --check-prefix=LARGE %s
|
||||
|
||||
// SMALL: "-mcmodel=small"
|
||||
// MEDIUM: "-mcmodel=medium"
|
||||
// LARGE: "-mcmodel=large"
|
||||
|
||||
// ERR-LARGE: error: unsupported argument 'large' to option '-mcmodel=' for target 'riscv32'
|
||||
// ERR-PIC-LARGE: error: invalid argument '-mcmodel=large' not allowed with '-fpic'
|
||||
|
||||
Reference in New Issue
Block a user