[PATCH] D132538: [AArch64] Filter out invalid code model in frontend.
Hsiangkai Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 24 01:34:27 PDT 2022
HsiangKai created this revision.
HsiangKai added reviewers: aemerson, paquette.
Herald added subscribers: StephenFan, kristof.beyls.
Herald added a project: All.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132538
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/mcmodel.c
Index: clang/test/Driver/mcmodel.c
===================================================================
--- clang/test/Driver/mcmodel.c
+++ clang/test/Driver/mcmodel.c
@@ -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: %clang -target aarch64 -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=AARCH64-MEDIUM %s
+// RUN: %clang -target aarch64 -### -c -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=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5421,6 +5421,9 @@
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132538.455104.patch
Type: text/x-patch
Size: 1524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220824/7f81ff51/attachment-0001.bin>
More information about the cfe-commits
mailing list