[clang] 7d669e6 - [AIX] Generate large code model relocations when mcmodel=medium on AIX

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 22 12:47:29 PDT 2021


Author: Anjan Kumar Guttahalli Krishna
Date: 2021-07-22T15:47:22-04:00
New Revision: 7d669e6666c1d67c1b4aecd90687013636d8037c

URL: https://github.com/llvm/llvm-project/commit/7d669e6666c1d67c1b4aecd90687013636d8037c
DIFF: https://github.com/llvm/llvm-project/commit/7d669e6666c1d67c1b4aecd90687013636d8037c.diff

LOG: [AIX] Generate large code model relocations when mcmodel=medium on AIX

This patch makes the changes in the driver that converts the medium code
model to large.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D106371

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 75bc32916371..0ebbad7e8877 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5136,11 +5136,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
     StringRef CM = A->getValue();
     if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" ||
-        CM == "tiny")
-      A->render(Args, CmdArgs);
-    else
+        CM == "tiny") {
+      if (Triple.isOSAIX() && CM == "medium")
+        CmdArgs.push_back("-mcmodel=large");
+      else
+        A->render(Args, CmdArgs);
+    } else {
       D.Diag(diag::err_drv_invalid_argument_to_option)
           << CM << A->getOption().getName();
+    }
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {

diff  --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index 8df5c6a7e38b..2c74c966744a 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -3,6 +3,8 @@
 // RUN: %clang -target x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=KERNEL %s
 // 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: %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
 
 // TINY: "-mcmodel=tiny"
@@ -10,5 +12,6 @@
 // KERNEL: "-mcmodel=kernel"
 // MEDIUM: "-mcmodel=medium"
 // LARGE: "-mcmodel=large"
+// AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
 
 // INVALID: error: invalid argument 'lager' to -mcmodel=


        


More information about the cfe-commits mailing list