SjoerdMeijer updated this revision to Diff 246491.
SjoerdMeijer added a comment.

Thanks, have added a note to the release notes, and also to the command line 
reference.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75056/new/

https://reviews.llvm.org/D75056

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/2009-10-20-GlobalDebug.c
  clang/test/Driver/no-common.c
  clang/test/Driver/rewrite-legacy-objc.m
  clang/test/Driver/rewrite-objc.m
  clang/test/Frontend/ast-codegen.c

Index: clang/test/Frontend/ast-codegen.c
===================================================================
--- clang/test/Frontend/ast-codegen.c
+++ clang/test/Frontend/ast-codegen.c
@@ -5,7 +5,7 @@
 // CHECK: module asm "foo"
 __asm__("foo");
 
-// CHECK: @g0 = common dso_local global i32 0, align 4
+// CHECK: @g0 = dso_local global i32 0, align 4
 int g0;
 
 // CHECK: define dso_local i32 @f0()
Index: clang/test/Driver/rewrite-objc.m
===================================================================
--- clang/test/Driver/rewrite-objc.m
+++ clang/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fno-common" "-fdiagnostics-show-option"
Index: clang/test/Driver/rewrite-legacy-objc.m
===================================================================
--- clang/test/Driver/rewrite-legacy-objc.m
+++ clang/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fno-common" "-fdiagnostics-show-option"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
-// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fno-common" "-fdiagnostics-show-option"
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fno-common" "-fdiagnostics-show-option"
Index: clang/test/Driver/no-common.c
===================================================================
--- /dev/null
+++ clang/test/Driver/no-common.c
@@ -0,0 +1,39 @@
+// RUN: %clang --target=armv7-arm-none-eabi -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=armv7-arm-none-eabi -mbig-endian -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=armebv7-arm-none-eabi -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=thumbv8a-arm-none-eabi -### -c %s 2>&1  | FileCheck %s
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -mbig-endian -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=thumbv8a-arm-none-eabi -mbig-endian -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=thumbebv8a-arm-none-eabi -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=aarch64_be-arm-none-eabi -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=armv8a-arm-none-eabi -fcommon -fno-common -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=mips32 -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=mips32el -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=mips64 -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=mips64el -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=powerpc -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=powerpc64 -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=powerpc64le -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=sparc -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=sparcel -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=sparcv9 -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=sparc64 -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=wasm32-unknown -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=wasm64-unknown -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=x86-none -### -c %s 2>&1 | FileCheck %s
+// RUN: %clang --target=x86_64-none -### -c %s 2>&1 | FileCheck %s
+
+// RUN: %clang --target=xcore-unknown -### -c %s 2>&1 | FileCheck %s
+
+// CHECK:     "-fno-common"
+// CHECK-NOT: "-fcommon"
Index: clang/test/CodeGen/2009-10-20-GlobalDebug.c
===================================================================
--- clang/test/CodeGen/2009-10-20-GlobalDebug.c
+++ clang/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -2,10 +2,10 @@
 // RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s
 
 // CHECK: @main.localstatic = internal global i32 0, align 4, !dbg [[L:![0-9]+]]
-// CHECK: @global = common global i32 0, align 4, !dbg [[G:![0-9]+]]
+// CHECK: @global = global i32 0, align 4, !dbg [[G:![0-9]+]]
 
 int global;
-int main() { 
+int main() {
   static int localstatic;
   return 0;
 }
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1408,20 +1408,6 @@
   }
 }
 
-static bool isNoCommonDefault(const llvm::Triple &Triple) {
-  switch (Triple.getArch()) {
-  default:
-    if (Triple.isOSFuchsia())
-      return true;
-    return false;
-
-  case llvm::Triple::xcore:
-  case llvm::Triple::wasm32:
-  case llvm::Triple::wasm64:
-    return true;
-  }
-}
-
 static bool hasMultipleInvocations(const llvm::Triple &Triple,
                                    const ArgList &Args) {
   // Supported only on Darwin where we invoke the compiler multiple times
@@ -5661,10 +5647,10 @@
   if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
     CmdArgs.push_back("-Qn");
 
-  // -fcommon is the default unless compiling kernel code or the target says so
-  bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple);
-  if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common,
-                    !NoCommonDefault))
+  // -fno-common is the default, set -fcommon only when that flag is set.
+  if (Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, false))
+    CmdArgs.push_back("-fcommon");
+  else
     CmdArgs.push_back("-fno-common");
 
   // -fsigned-bitfields is default, and clang doesn't yet support
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -84,6 +84,7 @@
 Modified Compiler Flags
 -----------------------
 
+- -fno-common has been enabled as the default for all targets.
 
 New Pragmas in Clang
 --------------------
Index: clang/docs/ClangCommandLineReference.rst
===================================================================
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -1307,6 +1307,10 @@
 
 .. option:: -fcommon, -fno-common
 
+Place definitions of variables with no storage class and no initializer
+(tentative definitions) in a common block, or generate individual
+zero-initialized definitions (default -fno-common).
+
 .. option:: -fcompile-resource=<arg>, --resource <arg>, --resource=<arg>
 
 .. option:: -fconstant-cfstrings, -fno-constant-cfstrings
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to