[clang] 4704eaf - [PowerPC] Support more mcmodel options for AIX (#70652)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 5 21:24:11 PST 2023


Author: Qiu Chaofan
Date: 2023-11-06T13:24:07+08:00
New Revision: 4704eaf234c3c30117caacd7b073d6dd63fd0f65

URL: https://github.com/llvm/llvm-project/commit/4704eaf234c3c30117caacd7b073d6dd63fd0f65
DIFF: https://github.com/llvm/llvm-project/commit/4704eaf234c3c30117caacd7b073d6dd63fd0f65.diff

LOG: [PowerPC] Support more mcmodel options for AIX (#70652)

7e42545 rejects unsupported mcmodel options, but small and large
should be a supported model for 32-bit AIX targets.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/mcmodel.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8bf07a10274e737..3e2c13069612876 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5726,16 +5726,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
     StringRef CM = A->getValue();
     bool Ok = false;
-    if (Triple.isOSAIX() && CM == "medium") {
+    if (Triple.isOSAIX() && CM == "medium")
       CM = "large";
-      Ok = true;
-    }
     if (Triple.isAArch64(64)) {
       Ok = CM == "tiny" || CM == "small" || CM == "large";
       if (CM == "large" && RelocationModel != llvm::Reloc::Static)
         D.Diag(diag::err_drv_argument_only_allowed_with)
             << A->getAsString(Args) << "-fno-pic";
-    } else if (Triple.isPPC64()) {
+    } else if (Triple.isPPC64() || Triple.isOSAIX()) {
       Ok = CM == "small" || CM == "medium" || CM == "large";
     } else if (Triple.isRISCV()) {
       if (CM == "medlow")

diff  --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index fb3bbccb0c68157..d8a41b0f5abd9aa 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -5,6 +5,8 @@
 // RUN: %clang --target=x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
 // RUN: %clang --target=x86_64 -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
 // RUN: not %clang -### -c --target=powerpc-linux-gnu -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
+// RUN: %clang --target=powerpc-unknown-aix -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=SMALL %s
+// RUN: %clang --target=powerpc-unknown-aix -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
 // 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


        


More information about the cfe-commits mailing list