stevewan created this revision. stevewan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
On AIX, the default arch level should match the minimum supported arch level of the OS version Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D97823 Files: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/aix-mcpu-default.c Index: clang/test/Driver/aix-mcpu-default.c =================================================================== --- clang/test/Driver/aix-mcpu-default.c +++ clang/test/Driver/aix-mcpu-default.c @@ -1,10 +1,18 @@ -// Check that the target cpu defaults to power4 on AIX. +// Check that the target cpu defaults to power7 on AIX7.2 and up. // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ -// RUN: -target powerpc-ibm-aix \ -// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s -// CHECK-MCPU-DEFAULT-NOT: warning: -// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1" -// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4" +// RUN: -target powerpc-ibm-aix7.2 \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s +// CHECK-MCPU-DEFAULT-AIX72-NOT: warning: +// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7" + +// Check that the target cpu defaults to power4 on AIX7.1 and below. +// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ +// RUN: -target powerpc-ibm-aix7.1 \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s +// CHECK-MCPU-DEFAULT-AIX71-NOT: warning: +// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4" // Check that the user is able to overwrite the default with '-mcpu'. // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -399,9 +399,11 @@ if (!TargetCPUName.empty()) return TargetCPUName; - if (T.isOSAIX()) - TargetCPUName = "pwr4"; - else if (T.getArch() == llvm::Triple::ppc64le) + if (T.isOSAIX()) { + unsigned major, minor, micro; + T.getOSVersion(major, minor, micro); + TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7"; + } else if (T.getArch() == llvm::Triple::ppc64le) TargetCPUName = "ppc64le"; else if (T.getArch() == llvm::Triple::ppc64) TargetCPUName = "ppc64";
Index: clang/test/Driver/aix-mcpu-default.c =================================================================== --- clang/test/Driver/aix-mcpu-default.c +++ clang/test/Driver/aix-mcpu-default.c @@ -1,10 +1,18 @@ -// Check that the target cpu defaults to power4 on AIX. +// Check that the target cpu defaults to power7 on AIX7.2 and up. // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ -// RUN: -target powerpc-ibm-aix \ -// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s -// CHECK-MCPU-DEFAULT-NOT: warning: -// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1" -// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4" +// RUN: -target powerpc-ibm-aix7.2 \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s +// CHECK-MCPU-DEFAULT-AIX72-NOT: warning: +// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7" + +// Check that the target cpu defaults to power4 on AIX7.1 and below. +// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ +// RUN: -target powerpc-ibm-aix7.1 \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s +// CHECK-MCPU-DEFAULT-AIX71-NOT: warning: +// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4" // Check that the user is able to overwrite the default with '-mcpu'. // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -399,9 +399,11 @@ if (!TargetCPUName.empty()) return TargetCPUName; - if (T.isOSAIX()) - TargetCPUName = "pwr4"; - else if (T.getArch() == llvm::Triple::ppc64le) + if (T.isOSAIX()) { + unsigned major, minor, micro; + T.getOSVersion(major, minor, micro); + TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7"; + } else if (T.getArch() == llvm::Triple::ppc64le) TargetCPUName = "ppc64le"; else if (T.getArch() == llvm::Triple::ppc64) TargetCPUName = "ppc64";
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits