[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden

Douglas Yung via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 11 12:39:39 PDT 2018


dyung created this revision.
dyung added a reviewer: probinson.

For compatibility reasons, the PS4 clang ABI must use version 6, so we force the compiler to use this version if the PS4 target triple is specified. We also emit a new warning now if a clang abi version was specified which is not 6 to let the user know we are ignoring their request.


Repository:
  rC Clang

https://reviews.llvm.org/D46767

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/alignment.cpp
  test/Driver/clang-abi-compat.cpp


Index: test/Driver/clang-abi-compat.cpp
===================================================================
--- test/Driver/clang-abi-compat.cpp
+++ test/Driver/clang-abi-compat.cpp
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring requested version
+
Index: test/CodeGenCXX/alignment.cpp
===================================================================
--- test/CodeGenCXX/alignment.cpp
+++ test/CodeGenCXX/alignment.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 -fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// Check that the PS4 target uses the 6.0 compat settings.
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 -fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
 
 extern int int_source();
 extern void int_sink(int x);
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2751,6 +2751,16 @@
           << A->getAsString(Args) << A->getValue();
     }
   }
+  // The PS4 requires version 6 of the clang ABI.
+  if (T.isPS4()) {
+    // Issue a warning if another version of the ABI was requested.
+    if (Args.getLastArg(OPT_fclang_abi_compat_EQ) &&
+        Opts.getClangABICompat() != LangOptions::ClangABI::Ver6) {
+      Diags.Report(diag::warn_drv_ignored_clang_abi_version)
+        << 6;
+    }
+    Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
+  }
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -149,6 +149,9 @@
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup<UnknownArgument>;
+def warn_drv_ignored_clang_abi_version : Warning<
+  "target requires clang ABI version %0, ignoring requested version">,
+  InGroup<UnusedCommandLineArgument>;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46767.146388.patch
Type: text/x-patch
Size: 2991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180511/524dcc9e/attachment.bin>


More information about the cfe-commits mailing list