[PATCH] D75056: [ARM][AArch64] Default to -fno-common

Sjoerd Meijer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 24 08:21:57 PST 2020


SjoerdMeijer created this revision.
Herald added a subscriber: kristof.beyls.

This patch proposes to default to `-fno-common` for the Arm targets because this has performance and code-size benefits.

Additionally, GCC now also defaults to this, so we would be behaving the same as GCC:

  commit 6271dd984d7f920d4fb17ad37af6a1f8e6b796dc
  Author: Wilco Dijkstra <wdijkstr at arm.com>
  Date:   Wed Nov 20 16:29:23 2019 +0000
      PR85678: Change default to -fno-common
      GCC currently defaults to -fcommon.  As discussed in the PR, this is an ancient
      C feature which is not conforming with the latest C standards.  On many targets
      this means global variable accesses have a codesize and performance penalty.
      This applies to C code only, C++ code is not affected by -fcommon.  It is about
      time to change the default.


https://reviews.llvm.org/D75056

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/triple-arm-none.c


Index: clang/test/Driver/triple-arm-none.c
===================================================================
--- /dev/null
+++ clang/test/Driver/triple-arm-none.c
@@ -0,0 +1,38 @@
+// RUN: %clang --target=armv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32LITTLE
+
+// RUN: %clang --target=armv7-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+// RUN: %clang --target=armebv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -### -c %s 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=CHECK --check-prefix=T32LITTLE
+// RUN: %clang --target=thumbv8a-arm-none-eabi -### -c %s 2>&1  | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=T32BIG
+// RUN: %clang --target=thumbv8a-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+// RUN: %clang --target=thumbebv8a-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=aarch64_be-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A64BIG
+
+// A32LITTLE: Target: armv7-arm-none-eabi
+// A64LITTLE: Target: aarch64-arm-none-eabi
+// A64BIG: Target: aarch64_be-arm-none-eabi
+
+// CHECK: "-cc1"
+// CHECK-NOT: "-no-integrated-as"
+
+// A32LITTLE: "-triple" "armv7-arm-none-eabi"
+// A32BIG: "-triple" "armebv7-arm-none-eabi"
+// T32LITTLE: "-triple" "thumbv8-arm-none-eabi"
+// T32BIG: "-triple" "thumbebv8-arm-none-eabi"
+// A64LITTLE: "-triple" "aarch64-arm-none-eabi"
+// A64BIG: "-triple" "aarch64_be-arm-none-eabi"
+
+// CHECK: "-fno-common"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1415,6 +1415,12 @@
       return true;
     return false;
 
+  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be:
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75056.246221.patch
Type: text/x-patch
Size: 2431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200224/22130d58/attachment-0001.bin>


More information about the cfe-commits mailing list