[AArch64] Filter out invalid code model in frontend.

AArch64 only supports tiny, small, and large code model. Show error
messages when users specify other code model.

Fix https://github.com/llvm/llvm-project/issues/53402

Differential Revision: https://reviews.llvm.org/D132538
This commit is contained in:
Hsiangkai Wang 2022-08-24 08:25:32 +00:00
parent 4e3bf225b7
commit a869014305
2 changed files with 8 additions and 0 deletions

View File

@ -5421,6 +5421,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CM == "tiny") {
if (Triple.isOSAIX() && CM == "medium")
CmdArgs.push_back("-mcmodel=large");
else if (Triple.isAArch64() && (CM == "kernel" || CM == "medium"))
D.Diag(diag::err_drv_invalid_argument_to_option)
<< CM << A->getOption().getName();
else
A->render(Args, CmdArgs);
} else {

View File

@ -6,6 +6,8 @@
// RUN: %clang -target powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log
// RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
// RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang -c -target aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=AARCH64-MEDIUM %s
// RUN: not %clang -c -target aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=AARCH64-KERNEL %s
// TINY: "-mcmodel=tiny"
// SMALL: "-mcmodel=small"
@ -15,3 +17,6 @@
// AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
// INVALID: error: invalid argument 'lager' to -mcmodel=
// AARCH64-MEDIUM: error: invalid argument 'medium' to -mcmodel=
// AARCH64-KERNEL: error: invalid argument 'kernel' to -mcmodel=