[clang] 4e36356 - Revert "[Driver] Default to -fno-common for all targets"
Sjoerd Meijer via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 02:00:57 PST 2020
Author: Sjoerd Meijer
Date: 2020-03-03T10:00:36Z
New Revision: 4e363563fa149321514389a031fa063e998d7422
URL: https://github.com/llvm/llvm-project/commit/4e363563fa149321514389a031fa063e998d7422
DIFF: https://github.com/llvm/llvm-project/commit/4e363563fa149321514389a031fa063e998d7422.diff
LOG: Revert "[Driver] Default to -fno-common for all targets"
This reverts commit 0a9fc9233e172601e26381810d093e02ef410f65.
Going to look at the asan failures.
I find the failures in the test suite weird, because they look
like compile time test and I don't understand how that can be
failing, but will have a brief look at that too.
Added:
clang/test/CodeGen/weak-global.c
Modified:
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
clang/test/CodeGen/2009-10-20-GlobalDebug.c
clang/test/CodeGen/aarch64-sve.c
clang/test/CodeGen/address-space.c
clang/test/CodeGen/alias.c
clang/test/CodeGen/align-systemz.c
clang/test/CodeGen/alignment.c
clang/test/CodeGen/asm-label.c
clang/test/CodeGen/attr-weak-import.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/attributes.c
clang/test/CodeGen/blocks-windows.c
clang/test/CodeGen/bool-convert.c
clang/test/CodeGen/c11atomics.c
clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
clang/test/CodeGen/cfstring-windows.c
clang/test/CodeGen/default-address-space.c
clang/test/CodeGen/dllexport-1.c
clang/test/CodeGen/dllexport.c
clang/test/CodeGen/dllimport.c
clang/test/CodeGen/microsoft-no-common-align.c
clang/test/CodeGen/no-common.c
clang/test/CodeGen/pr25786.c
clang/test/CodeGen/pragma-pack-1.c
clang/test/CodeGen/pragma-weak.c
clang/test/CodeGen/private-extern-redef.c
clang/test/CodeGen/tentative-decls.c
clang/test/CodeGen/tls-model.c
clang/test/CodeGen/visibility.c
clang/test/CodeGen/vlt_to_pointer.c
clang/test/CodeGen/volatile-1.c
clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
clang/test/CodeGenCXX/clang-sections-tentative.c
clang/test/CodeGenObjC/constant-string-class.m
clang/test/CodeGenObjC/tentative-cfconstantstring.m
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
clang/test/Driver/apple-kext-mkernel.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fuchsia.c
clang/test/Driver/xcore-opts.c
clang/test/Frontend/ast-codegen.c
clang/test/Headers/xmmintrin.c
clang/test/PCH/chain-external-defs.c
clang/test/PCH/external-defs.c
clang/test/PCH/tentative-defs.c
clang/test/Parser/pragma-visibility2.c
Removed:
clang/test/Driver/no-common.c
################################################################################
diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst
index 5af9d64ae0fc..609e7fa66c00 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1307,10 +1307,6 @@ Use colors in diagnostics
.. option:: -fcommon, -fno-common
-Place definitions of variables with no storage class and no initializer
-(tentative definitions) in a common block, instead of generating individual
-zero-initialized definitions (default -fno-common).
-
.. option:: -fcompile-resource=<arg>, --resource <arg>, --resource=<arg>
.. option:: -fconstant-cfstrings, -fno-constant-cfstrings
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 664ae4e4167c..ce121ebe6055 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,13 +84,6 @@ future versions of Clang.
Modified Compiler Flags
-----------------------
-- -fno-common has been enabled as the default for all targets. Therefore, C
- code that uses tentative definitions as definitions of a variable in multiple
- translation units will trigger multiple-definition linker errors. Generally,
- this occurs when the use of the ``extern`` keyword is neglected in the declaration
- of a variable in a header file. In some cases, no specific translation unit
- provides a definition of the variable. The previous behavior can be restored by
- specifying ``-fcommon``.
New Pragmas in Clang
--------------------
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 8d6256580615..f1801e3e89e7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -848,8 +848,7 @@ def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
Group<f_clang_Group>;
def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
-def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
- Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">;
+def fcommon : Flag<["-"], "fcommon">, Group<f_Group>;
def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group<f_Group>;
def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group<f_clang_Group>,
Flags<[CoreOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index db6847a4c211..d387a1dc2079 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1408,6 +1408,20 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
}
}
+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,9 +5675,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
CmdArgs.push_back("-Qn");
- // -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");
+ // -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))
+ CmdArgs.push_back("-fno-common");
// -fsigned-bitfields is default, and clang doesn't yet support
// -funsigned-bitfields.
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index e7b7e0f2b138..8638d4300b21 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -809,7 +809,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.RecordCommandLine =
std::string(Args.getLastArgValue(OPT_record_command_line));
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
- Opts.NoCommon = !Args.hasArg(OPT_fcommon);
+ Opts.NoCommon = Args.hasArg(OPT_fno_common);
Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Opts.OptimizeSize = getOptimizationLevelSize(Args);
diff --git a/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c b/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
index 89ec60282f88..3c9591e2945e 100644
--- a/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
+++ b/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
@@ -3,6 +3,6 @@
int g0, f0();
int f1(), g1;
-// CHECK: @g0 = {{(dso_local )?}}global i32 0, align 4
-// CHECK: @g1 = {{(dso_local )?}}global i32 0, align 4
+// CHECK: @g0 = common {{(dso_local )?}}global i32 0, align 4
+// CHECK: @g1 = common {{(dso_local )?}}global i32 0, align 4
diff --git a/clang/test/CodeGen/2009-10-20-GlobalDebug.c b/clang/test/CodeGen/2009-10-20-GlobalDebug.c
index 14b832013630..c8c247f6b041 100644
--- a/clang/test/CodeGen/2009-10-20-GlobalDebug.c
+++ b/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 = global i32 0, align 4, !dbg [[G:![0-9]+]]
+// CHECK: @global = common global i32 0, align 4, !dbg [[G:![0-9]+]]
int global;
-int main() {
+int main() {
static int localstatic;
return 0;
}
diff --git a/clang/test/CodeGen/aarch64-sve.c b/clang/test/CodeGen/aarch64-sve.c
index 790b3a176182..bb4512d5ed93 100644
--- a/clang/test/CodeGen/aarch64-sve.c
+++ b/clang/test/CodeGen/aarch64-sve.c
@@ -16,7 +16,7 @@
// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat64_t'
// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
-// CHECK: @ptr = global <vscale x 16 x i8>* null, align 8
+// CHECK: @ptr = common global <vscale x 16 x i8>* null, align 8
// CHECK: %s8 = alloca <vscale x 16 x i8>, align 16
// CHECK: %s16 = alloca <vscale x 8 x i16>, align 16
// CHECK: %s32 = alloca <vscale x 4 x i32>, align 16
diff --git a/clang/test/CodeGen/address-space.c b/clang/test/CodeGen/address-space.c
index c66dfc87c0c0..a76d2e743e6e 100644
--- a/clang/test/CodeGen/address-space.c
+++ b/clang/test/CodeGen/address-space.c
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,X86 %s
// RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,AMDGCN %s
-// CHECK: @foo = addrspace(1) global
+// CHECK: @foo = common addrspace(1) global
int foo __attribute__((address_space(1)));
-// CHECK: @ban = addrspace(1) global
+// CHECK: @ban = common addrspace(1) global
int ban[10] __attribute__((address_space(1)));
-// CHECK: @a = global
+// CHECK: @a = common global
int a __attribute__((address_space(0)));
// CHECK-LABEL: define i32 @test1()
diff --git a/clang/test/CodeGen/alias.c b/clang/test/CodeGen/alias.c
index 21483cfb950b..f5bdf3c0587e 100644
--- a/clang/test/CodeGen/alias.c
+++ b/clang/test/CodeGen/alias.c
@@ -5,13 +5,8 @@
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
int g0;
-// CHECKBASIC-DAG: @g0 = global i32 0
-// CHECKASM-DAG: .bss
-// CHECKASM-DAG: .globl g0
-// CHECKASM-DAG: .p2align 2
-// CHECKASM-DAG: g0:
-// CHECKASM-DAG: .long 0
-// CHECKASM-DAG: .size g0, 4
+// CHECKBASIC-DAG: @g0 = common global i32 0
+// CHECKASM-DAG: .comm g0,4,4
__thread int TL_WITH_ALIAS;
// CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4
// CHECKASM-DAG: .globl TL_WITH_ALIAS
diff --git a/clang/test/CodeGen/align-systemz.c b/clang/test/CodeGen/align-systemz.c
index 9a6c22238327..eaa1de64d344 100644
--- a/clang/test/CodeGen/align-systemz.c
+++ b/clang/test/CodeGen/align-systemz.c
@@ -7,10 +7,10 @@ struct test {
};
char c;
-// CHECK-DAG: @c = global i8 0, align 2
+// CHECK-DAG: @c = common global i8 0, align 2
struct test s;
-// CHECK-DAG: @s = global %struct.test zeroinitializer, align 2
+// CHECK-DAG: @s = common global %struct.test zeroinitializer, align 2
extern char ec;
// CHECK-DAG: @ec = external global i8, align 2
diff --git a/clang/test/CodeGen/alignment.c b/clang/test/CodeGen/alignment.c
index ce0c58bee4bb..c9f58136e38a 100644
--- a/clang/test/CodeGen/alignment.c
+++ b/clang/test/CodeGen/alignment.c
@@ -7,7 +7,7 @@ union {int a[4]; __attribute((aligned(16))) float b[4];} b;
// CHECK: @b = {{.*}}zeroinitializer, align 16
long long int test5[1024];
-// CHECK-DAG: @test5 = global [1024 x i64] zeroinitializer, align 8
+// CHECK-DAG: @test5 = common global [1024 x i64] zeroinitializer, align 8
// PR5279 - Reduced alignment on typedef.
typedef int myint __attribute__((aligned(1)));
diff --git a/clang/test/CodeGen/asm-label.c b/clang/test/CodeGen/asm-label.c
index 7c7383fa41fc..c06f11fd2d24 100644
--- a/clang/test/CodeGen/asm-label.c
+++ b/clang/test/CodeGen/asm-label.c
@@ -11,9 +11,9 @@ int *test(void) {
}
// LINUX: @bar = internal global i32 0
-// LINUX: @foo = global i32 0
+// LINUX: @foo = common global i32 0
// LINUX: declare i8* @alias(i32)
// DARWIN: @"\01bar" = internal global i32 0
-// DARWIN: @"\01foo" = global i32 0
+// DARWIN: @"\01foo" = common global i32 0
// DARWIN: declare i8* @"\01alias"(i32)
diff --git a/clang/test/CodeGen/attr-weak-import.c b/clang/test/CodeGen/attr-weak-import.c
index f02d09e81509..0707f59a608b 100644
--- a/clang/test/CodeGen/attr-weak-import.c
+++ b/clang/test/CodeGen/attr-weak-import.c
@@ -20,7 +20,7 @@ extern int E __attribute__((weak_import));
// CHECK: @A = global i32
// CHECK-NOT: @B =
-// CHECK: @C = global i32
+// CHECK: @C = common global i32
// CHECK: @D = global i32
// CHECK: @E = global i32
diff --git a/clang/test/CodeGen/attr-weakref2.c b/clang/test/CodeGen/attr-weakref2.c
index 114f048a8518..99760635581d 100644
--- a/clang/test/CodeGen/attr-weakref2.c
+++ b/clang/test/CodeGen/attr-weakref2.c
@@ -8,7 +8,7 @@ int test1_h(void) {
return test1_g;
}
-// CHECK: @test2_f = global i32 0, align 4
+// CHECK: @test2_f = common global i32 0, align 4
int test2_f;
static int test2_g __attribute__((weakref("test2_f")));
int test2_h(void) {
@@ -25,7 +25,7 @@ int test3_h(void) {
return test3_g;
}
-// CHECK: @test4_f = global i32 0, align 4
+// CHECK: @test4_f = common global i32 0, align 4
extern int test4_f;
static int test4_g __attribute__((weakref("test4_f")));
int test4_h(void) {
diff --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index f6323e9be548..4be38b6367dc 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -20,7 +20,7 @@ int t18 = 1;
// CHECK: @t16 = extern_weak global i32
extern int t16 __attribute__((weak_import));
-// CHECK: @t6 = protected global i32 0
+// CHECK: @t6 = common protected global i32 0
int t6 __attribute__((visibility("protected")));
// CHECK: @t12 = global i32 0, section "SECT"
diff --git a/clang/test/CodeGen/blocks-windows.c b/clang/test/CodeGen/blocks-windows.c
index 44e5f66525b2..2dd97ffdd2f3 100644
--- a/clang/test/CodeGen/blocks-windows.c
+++ b/clang/test/CodeGen/blocks-windows.c
@@ -68,7 +68,7 @@ int (*g(void))(void) {
}
// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local dllexport global i8*
-// CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = dso_local dllexport global [5 x i32]
+// CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local dllexport global [5 x i32]
// CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport global i8*
// CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN: @_NSConcreteStackBlock = external dllimport global i8*
// CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN-DLLIMPORT: @_NSConcreteStackBlock = external dllimport global i8*
diff --git a/clang/test/CodeGen/bool-convert.c b/clang/test/CodeGen/bool-convert.c
index 745971446e61..344fb6bb994a 100644
--- a/clang/test/CodeGen/bool-convert.c
+++ b/clang/test/CodeGen/bool-convert.c
@@ -2,16 +2,16 @@
// All of these should uses the memory representation of _Bool
// CHECK-LABEL: %struct.teststruct1 = type { i8, i8 }
-// CHECK-LABEL: @test1 = global %struct.teststruct1
+// CHECK-LABEL: @test1 = common global %struct.teststruct1
struct teststruct1 {_Bool a, b;} test1;
-// CHECK-LABEL: @test2 = global i8* null
+// CHECK-LABEL: @test2 = common global i8* null
_Bool* test2;
-// CHECK-LABEL: @test3 = global [10 x i8]
+// CHECK-LABEL: @test3 = common global [10 x i8]
_Bool test3[10];
-// CHECK-LABEL: @test4 = global [0 x i8]* null
+// CHECK-LABEL: @test4 = common global [0 x i8]* null
_Bool (*test4)[];
// CHECK-LABEL: define void @f(i32 %x)
diff --git a/clang/test/CodeGen/c11atomics.c b/clang/test/CodeGen/c11atomics.c
index 0a32ebcc724e..cf251738be55 100644
--- a/clang/test/CodeGen/c11atomics.c
+++ b/clang/test/CodeGen/c11atomics.c
@@ -25,7 +25,7 @@ struct elem {
// CHECK-DAG: %struct.elem = type { %struct.ptr }
struct ptr object;
-// CHECK-DAG: @object = global %struct.ptr zeroinitializer
+// CHECK-DAG: @object = common global %struct.ptr zeroinitializer
// CHECK-DAG: @testStructGlobal = global {{.*}} { i16 1, i16 2, i16 3, i16 4 }
// CHECK-DAG: @testPromotedStructGlobal = global {{.*}} { %{{.*}} { i16 1, i16 2, i16 3 }, [2 x i8] zeroinitializer }
diff --git a/clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c b/clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
index e330624ead96..8b90d7c0c1d8 100644
--- a/clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
+++ b/clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
@@ -30,7 +30,7 @@ const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("
// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external global [0 x i32]
-// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = global [32 x i64] zeroinitializer, align 16
-// CHECK-CF: @__CFConstantStringClassReference = global [1 x i64] zeroinitializer, align 8
+// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common global [32 x i64] zeroinitializer, align 16
+// CHECK-CF: @__CFConstantStringClassReference = common global [1 x i64] zeroinitializer, align 8
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external global [0 x i32]
// CHECK-CF-EXTERN: @.str = private unnamed_addr constant [7 x i8] c"string\00", section ".rodata", align 1
diff --git a/clang/test/CodeGen/cfstring-windows.c b/clang/test/CodeGen/cfstring-windows.c
index 7c17f31d3dd4..fe7511eae141 100644
--- a/clang/test/CodeGen/cfstring-windows.c
+++ b/clang/test/CodeGen/cfstring-windows.c
@@ -32,7 +32,7 @@ typedef struct __CFString *CFStringRef;
const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("string");
// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external dso_local dllexport global [0 x i32]
-// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = dso_local dllexport global [32 x i32]
+// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common dso_local dllexport global [32 x i32]
// CHECK-CF: @__CFConstantStringClassReference = external dllimport global [0 x i32]
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external dllimport global [0 x i32]
// CHECK-CF-EXTERN-DLLIMPORT: @__CFConstantStringClassReference = external dllimport global [0 x i32]
diff --git a/clang/test/CodeGen/default-address-space.c b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..5450609e06bb 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s
-// CHECK-DAG: @foo = addrspace(1) global i32 0
+// CHECK-DAG: @foo = common addrspace(1) global i32 0
int foo;
-// CHECK-DAG: @ban = addrspace(1) global [10 x i32] zeroinitializer
+// CHECK-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer
int ban[10];
-// CHECK-DAG: @A = addrspace(1) global i32* null
-// CHECK-DAG: @B = addrspace(1) global i32* null
+// CHECK-DAG: @A = common addrspace(1) global i32* null
+// CHECK-DAG: @B = common addrspace(1) global i32* null
int *A;
int *B;
diff --git a/clang/test/CodeGen/dllexport-1.c b/clang/test/CodeGen/dllexport-1.c
index b24324b0a96e..5860591c83c7 100644
--- a/clang/test/CodeGen/dllexport-1.c
+++ b/clang/test/CodeGen/dllexport-1.c
@@ -9,8 +9,8 @@
// CHECK-MSVC: @z = dso_local constant i32 4, align 4
// CHECK-LNX: @z = constant i32 4, align 4
-// CHECK-MSVC: @y = dso_local dllexport constant i32 0, align 4
-// CHECK-LNX: @y = constant i32 0, align 4
+// CHECK-MSVC: @y = common dso_local dllexport global i32 0, align 4
+// CHECK-LNX: @y = common global i32 0, align 4
__declspec(dllexport) int const x = 3;
__declspec(dllexport) const int y;
diff --git a/clang/test/CodeGen/dllexport.c b/clang/test/CodeGen/dllexport.c
index 4c1143cf5ca4..f27012ec2355 100644
--- a/clang/test/CodeGen/dllexport.c
+++ b/clang/test/CodeGen/dllexport.c
@@ -14,7 +14,7 @@
__declspec(dllexport) extern int ExternGlobalDecl;
// dllexport implies a definition.
-// CHECK-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @GlobalDef = common dso_local dllexport global i32 0, align 4
__declspec(dllexport) int GlobalDef;
// Export definition.
@@ -27,11 +27,11 @@ __declspec(dllexport) extern int GlobalDeclInit;
int GlobalDeclInit = 1;
// Redeclarations
-// CHECK-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @GlobalRedecl1 = common dso_local dllexport global i32 0, align 4
__declspec(dllexport) extern int GlobalRedecl1;
__declspec(dllexport) int GlobalRedecl1;
-// CHECK-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @GlobalRedecl2 = common dso_local dllexport global i32 0, align 4
__declspec(dllexport) extern int GlobalRedecl2;
int GlobalRedecl2;
@@ -70,13 +70,13 @@ __declspec(dllexport) void redecl2(void);
//===----------------------------------------------------------------------===//
// dllexport takes precedence over the dllimport if both are specified.
-// CHECK-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
-// CHECK-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobal1A = common dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobal1B = common dso_local dllexport global i32 0, align 4
__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A;
__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B;
-// CHECK-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
-// CHECK-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobal2A = common dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobal2B = common dso_local dllexport global i32 0, align 4
__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A;
__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
@@ -84,7 +84,7 @@ __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
__declspec(dllexport) extern int PrecedenceGlobalRedecl1;
__declspec(dllimport) int PrecedenceGlobalRedecl1 = 0;
-// CHECK-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobalRedecl2 = common dso_local dllexport global i32 0, align 4
__declspec(dllimport) extern int PrecedenceGlobalRedecl2;
__declspec(dllexport) int PrecedenceGlobalRedecl2;
@@ -92,7 +92,7 @@ __declspec(dllexport) int PrecedenceGlobalRedecl2;
__attribute__((dllexport)) extern int PrecedenceGlobalMixed1;
__declspec(dllimport) int PrecedenceGlobalMixed1 = 1;
-// CHECK-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
+// CHECK-DAG: @PrecedenceGlobalMixed2 = common dso_local dllexport global i32 0, align 4
__attribute__((dllimport)) extern int PrecedenceGlobalMixed2;
__declspec(dllexport) int PrecedenceGlobalMixed2;
diff --git a/clang/test/CodeGen/dllimport.c b/clang/test/CodeGen/dllimport.c
index 8a67716fd9cf..319770232a28 100644
--- a/clang/test/CodeGen/dllimport.c
+++ b/clang/test/CodeGen/dllimport.c
@@ -46,8 +46,8 @@ __declspec(dllimport) extern int GlobalRedecl3;
USEVAR(GlobalRedecl3)
// Make sure this works even if the decl has been used before it's defined (PR20792).
-// MS: @GlobalRedecl4 = dso_local dllexport global i32
-// GNU: @GlobalRedecl4 = dso_local global i32
+// MS: @GlobalRedecl4 = common dso_local dllexport global i32
+// GNU: @GlobalRedecl4 = common dso_local global i32
__declspec(dllimport) extern int GlobalRedecl4;
USEVAR(GlobalRedecl4)
int GlobalRedecl4; // dllimport ignored
diff --git a/clang/test/CodeGen/microsoft-no-common-align.c b/clang/test/CodeGen/microsoft-no-common-align.c
index 7b7d91037fe4..a7a27a062704 100644
--- a/clang/test/CodeGen/microsoft-no-common-align.c
+++ b/clang/test/CodeGen/microsoft-no-common-align.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fcommon -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s
typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
typedef float NormalAlignment __attribute__((__vector_size__(4)));
diff --git a/clang/test/CodeGen/no-common.c b/clang/test/CodeGen/no-common.c
index 11de0f23396e..f3a6a334e6f5 100644
--- a/clang/test/CodeGen/no-common.c
+++ b/clang/test/CodeGen/no-common.c
@@ -1,16 +1,15 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
-// RUN: %clang_cc1 %s -fno-common -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
-// RUN: %clang_cc1 %s -fcommon -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-COMMON
+// RUN: %clang_cc1 %s -fno-common -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-NOCOMMON
-// CHECK-COMMON: @x = common {{(dso_local )?}}global
-// CHECK-DEFAULT: @x = {{(dso_local )?}}global
+// CHECK-DEFAULT: @x = common {{(dso_local )?}}global
+// CHECK-NOCOMMON: @x = {{(dso_local )?}}global
int x;
-// CHECK-COMMON: @ABC = {{(dso_local )?}}global
// CHECK-DEFAULT: @ABC = {{(dso_local )?}}global
+// CHECK-NOCOMMON: @ABC = {{(dso_local )?}}global
typedef void* (*fn_t)(long a, long b, char *f, int c);
fn_t ABC __attribute__ ((nocommon));
-// CHECK-COMMON: @y = common {{(dso_local )?}}global
// CHECK-DEFAULT: @y = common {{(dso_local )?}}global
+// CHECK-NOCOMMON: @y = common {{(dso_local )?}}global
int y __attribute__((common));
diff --git a/clang/test/CodeGen/pr25786.c b/clang/test/CodeGen/pr25786.c
index d24ab1ba41eb..612da7e8a369 100644
--- a/clang/test/CodeGen/pr25786.c
+++ b/clang/test/CodeGen/pr25786.c
@@ -4,8 +4,8 @@
void (__attribute__((regparm(3), stdcall)) *pf) ();
void (__attribute__((regparm(2), stdcall)) foo)(int a) {
}
-// CHECK: @pf = global void (...)* null
+// CHECK: @pf = common global void (...)* null
// CHECK: define void @foo(i32 %a)
-// CHECK-OK: @pf = global void (...)* null
+// CHECK-OK: @pf = common global void (...)* null
// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
diff --git a/clang/test/CodeGen/pragma-pack-1.c b/clang/test/CodeGen/pragma-pack-1.c
index 3a9e391c4ef3..773318c79f7c 100644
--- a/clang/test/CodeGen/pragma-pack-1.c
+++ b/clang/test/CodeGen/pragma-pack-1.c
@@ -64,5 +64,5 @@ struct S4
// CHECK: %struct.S4 = type { [3 x i8], %struct.T4, i32 }
// CHECK: %struct.T4 = type <{ i8, i32 }>
-// CHECK: @refs = global [[struct_ref]]
-// CHECK: @ss = global [[struct_S]]
+// CHECK: @refs = common global [[struct_ref]]
+// CHECK: @ss = common global [[struct_S]]
diff --git a/clang/test/CodeGen/pragma-weak.c b/clang/test/CodeGen/pragma-weak.c
index 28354dc031c6..d1f7ab6c3ebe 100644
--- a/clang/test/CodeGen/pragma-weak.c
+++ b/clang/test/CodeGen/pragma-weak.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm %s -o - -verify | FileCheck %s
// CHECK: @weakvar = weak global
-// CHECK: @__weakvar_alias = global
+// CHECK: @__weakvar_alias = common global
// CHECK: @correct_linkage = weak global
diff --git a/clang/test/CodeGen/private-extern-redef.c b/clang/test/CodeGen/private-extern-redef.c
index e0d51b67e228..580ce9bd4a08 100644
--- a/clang/test/CodeGen/private-extern-redef.c
+++ b/clang/test/CodeGen/private-extern-redef.c
@@ -34,6 +34,6 @@ void foo() {
// CHECK: @M = hidden global
// CHECK: @O = hidden global
// CHECK: @I = external hidden
-// CHECK: @N = hidden global
+// CHECK: @N = common hidden global
// CHECK-NOT: @P
diff --git a/clang/test/CodeGen/tentative-decls.c b/clang/test/CodeGen/tentative-decls.c
index e24c3fcee740..321778720587 100644
--- a/clang/test/CodeGen/tentative-decls.c
+++ b/clang/test/CodeGen/tentative-decls.c
@@ -1,16 +1,16 @@
// RUN: %clang_cc1 -emit-llvm -w -o - %s | FileCheck %s
-// CHECK-DAG: @r = {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
+// CHECK-DAG: @r = common {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
int r[];
int (*a)[] = &r;
struct s0;
struct s0 x;
-// CHECK-DAG: @x = {{(dso_local )?}}global %struct.s0 zeroinitializer
+// CHECK-DAG: @x = common {{(dso_local )?}}global %struct.s0 zeroinitializer
struct s0 y;
-// CHECK-DAG: @y = {{(dso_local )?}}global %struct.s0 zeroinitializer
+// CHECK-DAG: @y = common {{(dso_local )?}}global %struct.s0 zeroinitializer
struct s0 *f0() {
return &y;
}
@@ -19,14 +19,14 @@ struct s0 {
int x;
};
-// CHECK-DAG: @b = {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
+// CHECK-DAG: @b = common {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
int b[];
int *f1() {
return b;
}
// Check that the most recent tentative definition wins.
-// CHECK-DAG: @c = {{(dso_local )?}}global [4 x {{.*}}] zeroinitializer
+// CHECK-DAG: @c = common {{(dso_local )?}}global [4 x {{.*}}] zeroinitializer
int c[];
int c[4];
diff --git a/clang/test/CodeGen/tls-model.c b/clang/test/CodeGen/tls-model.c
index 313c3b1dfd41..41c8de0b0e89 100644
--- a/clang/test/CodeGen/tls-model.c
+++ b/clang/test/CodeGen/tls-model.c
@@ -21,24 +21,24 @@ int __thread __attribute__((tls_model("initial-exec"))) z;
// CHECK-GD: @z1 = global i32 0
// CHECK-GD: @f.y = internal thread_local global i32 0
-// CHECK-GD: @z2 = global i32 0
+// CHECK-GD: @z2 = common global i32 0
// CHECK-GD: @x = thread_local global i32 0
// CHECK-GD: @z = thread_local(initialexec) global i32 0
// CHECK-LD: @z1 = global i32 0
// CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0
-// CHECK-LD: @z2 = global i32 0
+// CHECK-LD: @z2 = common global i32 0
// CHECK-LD: @x = thread_local(localdynamic) global i32 0
// CHECK-LD: @z = thread_local(initialexec) global i32 0
// CHECK-IE: @z1 = global i32 0
// CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0
-// CHECK-IE: @z2 = global i32 0
+// CHECK-IE: @z2 = common global i32 0
// CHECK-IE: @x = thread_local(initialexec) global i32 0
// CHECK-IE: @z = thread_local(initialexec) global i32 0
// CHECK-LE: @z1 = global i32 0
// CHECK-LE: @f.y = internal thread_local(localexec) global i32 0
-// CHECK-LE: @z2 = global i32 0
+// CHECK-LE: @z2 = common global i32 0
// CHECK-LE: @x = thread_local(localexec) global i32 0
// CHECK-LE: @z = thread_local(initialexec) global i32 0
diff --git a/clang/test/CodeGen/visibility.c b/clang/test/CodeGen/visibility.c
index f5606a508a1e..8e153b893a3f 100644
--- a/clang/test/CodeGen/visibility.c
+++ b/clang/test/CodeGen/visibility.c
@@ -3,15 +3,15 @@
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
// CHECK-DEFAULT: @g_def = global i32 0
-// CHECK-DEFAULT: @g_com = global i32 0
+// CHECK-DEFAULT: @g_com = common global i32 0
// CHECK-DEFAULT: @g_ext = external global i32
// CHECK-DEFAULT: @g_deferred = internal global
// CHECK-PROTECTED: @g_def = protected global i32 0
-// CHECK-PROTECTED: @g_com = protected global i32 0
+// CHECK-PROTECTED: @g_com = common protected global i32 0
// CHECK-PROTECTED: @g_ext = external global i32
// CHECK-PROTECTED: @g_deferred = internal global
// CHECK-HIDDEN: @g_def = hidden global i32 0
-// CHECK-HIDDEN: @g_com = hidden global i32 0
+// CHECK-HIDDEN: @g_com = common hidden global i32 0
// CHECK-HIDDEN: @g_ext = external global i32
// CHECK-HIDDEN: @g_deferred = internal global
int g_com;
diff --git a/clang/test/CodeGen/vlt_to_pointer.c b/clang/test/CodeGen/vlt_to_pointer.c
index 12aaaa9a1df3..22c620aa6429 100644
--- a/clang/test/CodeGen/vlt_to_pointer.c
+++ b/clang/test/CodeGen/vlt_to_pointer.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
int c[1][3*2];
-// CHECK: @{{.+}} = global [1 x [6 x {{i[0-9]+}}]] zeroinitializer
+// CHECK: @{{.+}} = {{.*}} global [1 x [6 x {{i[0-9]+}}]] zeroinitializer
// CHECK-LABEL: @f
int f(int * const m, int (**v)[*m * 2])
diff --git a/clang/test/CodeGen/volatile-1.c b/clang/test/CodeGen/volatile-1.c
index a0c7093363d7..c62a8fd4cd3d 100644
--- a/clang/test/CodeGen/volatile-1.c
+++ b/clang/test/CodeGen/volatile-1.c
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -w -o - | FileCheck %s
-// CHECK: @i = {{(dso_local )?}}global [[INT:i[0-9]+]] 0
+// CHECK: @i = common {{(dso_local )?}}global [[INT:i[0-9]+]] 0
volatile int i, j, k;
volatile int ar[5];
volatile char c;
-// CHECK: @ci = {{(dso_local )?}}global [[CINT:.*]] zeroinitializer
+// CHECK: @ci = common {{(dso_local )?}}global [[CINT:.*]] zeroinitializer
volatile _Complex int ci;
volatile struct S {
#ifdef __cplusplus
diff --git a/clang/test/CodeGen/weak-global.c b/clang/test/CodeGen/weak-global.c
new file mode 100644
index 000000000000..f972cea91200
--- /dev/null
+++ b/clang/test/CodeGen/weak-global.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep common
+
+int i;
diff --git a/clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c b/clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
index f2c5ff94ffae..a2ebbf195f79 100644
--- a/clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
+++ b/clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
@@ -17,7 +17,7 @@ void call_imported_function() {
}
// CHECK: @import_int = external dllimport global i32
-// CHECK: @export_int = dso_local dllexport global i32 0, align 4
+// CHECK: @export_int = common dso_local dllexport global i32 0, align 4
// CHECK: define dso_local dllexport arm_aapcs_vfpcc void @export_implemented_function()
diff --git a/clang/test/CodeGenCXX/clang-sections-tentative.c b/clang/test/CodeGenCXX/clang-sections-tentative.c
index 2e3d3410bd36..e663079b9aa4 100644
--- a/clang/test/CodeGenCXX/clang-sections-tentative.c
+++ b/clang/test/CodeGenCXX/clang-sections-tentative.c
@@ -30,7 +30,7 @@ const int cy; // .rodata.2
// CHECK: @x = global i32 0, align 4 #0
// CHECK: @y = global i32 0, align 4 #1
-// CHECK: @z = global i32 0, align 4
+// CHECK: @z = common global i32 0, align 4
// CHECK: @cx = constant i32 0, align 4 #2
// CHECK: @cy = constant i32 0, align 4 #3
// CHECK: @cz = constant i32 0, align 4 #1
diff --git a/clang/test/CodeGenObjC/constant-string-class.m b/clang/test/CodeGenObjC/constant-string-class.m
index 47184050056b..adad6b012623 100644
--- a/clang/test/CodeGenObjC/constant-string-class.m
+++ b/clang/test/CodeGenObjC/constant-string-class.m
@@ -30,6 +30,6 @@ int main () {
return 0;
}
-// CHECK-FRAGILE: @_FooClassReference = global
+// CHECK-FRAGILE: @_FooClassReference = common global
// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = global
diff --git a/clang/test/CodeGenObjC/tentative-cfconstantstring.m b/clang/test/CodeGenObjC/tentative-cfconstantstring.m
index 978bcba6122b..bb76b033cf5f 100644
--- a/clang/test/CodeGenObjC/tentative-cfconstantstring.m
+++ b/clang/test/CodeGenObjC/tentative-cfconstantstring.m
@@ -31,7 +31,7 @@ -(void)someMethod {
}
@end
-// CHECK: @__CFConstantStringClassReference = global [24 x i32] zeroinitializer, align 16
+// CHECK: @__CFConstantStringClassReference = common global [24 x i32] zeroinitializer, align 16
// CHECK: @_unnamed_cfstring_{{.*}} = private global %struct.__NSConstantString_tag { i32* getelementptr inbounds ([24 x i32], [24 x i32]* @__CFConstantStringClassReference, i32 0, i32 0)
// CHECK-LABEL: define internal void @_inlineFunction()
diff --git a/clang/test/CodeGenOpenCL/address-spaces.cl b/clang/test/CodeGenOpenCL/address-spaces.cl
index 144466a690b3..3c8fea2a80bc 100644
--- a/clang/test/CodeGenOpenCL/address-spaces.cl
+++ b/clang/test/CodeGenOpenCL/address-spaces.cl
@@ -53,10 +53,10 @@ void fc(constant int *arg) {}
#ifdef CL20
int i;
-// CL20-DAG: @i = {{(dso_local )?}}addrspace(1) global i32 0
+// CL20-DAG: @i = common {{(dso_local )?}}addrspace(1) global i32 0
int *ptr;
// CL20SPIR-DAG: @ptr = {{(common )?}}{{(dso_local )?}}addrspace(1) global i32 addrspace(4)* null
-// CL20AMDGCN-DAG: @ptr = {{(dso_local )?}}addrspace(1) global i32* null
+// CL20AMDGCN-DAG: @ptr = common {{(dso_local )?}}addrspace(1) global i32* null
#endif
// SPIR: i32* %arg
diff --git a/clang/test/CodeGenOpenCL/amdgcn-large-globals.cl b/clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
index cf7db165f46b..ea9ea618a488 100644
--- a/clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
+++ b/clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
@@ -1,11 +1,11 @@
// REQUIRES: amdgpu-registered-target
// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
-// CHECK: @One = local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1
+// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1
unsigned char One[6442450944];
-// CHECK: @Two = local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4
+// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4
global unsigned int Two[6442450944];
-
+
kernel void large_globals(unsigned int id) {
One[id] = id;
Two[id + 1] = id + 1;
diff --git a/clang/test/CodeGenOpenCL/amdgpu-nullptr.cl b/clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
index ba34d168bf79..c7c77920b775 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -1,7 +1,6 @@
// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn---opencl -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fcommon -emit-llvm -o - | FileCheck %s --check-prefix=COMMON
typedef struct {
private char *p1;
@@ -17,6 +16,9 @@ typedef struct {
generic char *p5;
} StructTy2;
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
// Test 0 as initializer.
// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4
@@ -181,39 +183,34 @@ void test_func_scope_var_local(void) {
// cannot have common linkage since common linkage requires zero initialization
// and does not have explicit section.
-// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4
-// COMMON: @p1 = common local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4
+// CHECK: @p1 = common local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4
private char *p1;
-// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), align 4
-// COMMON: @p2 = weak local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), align 4
+// CHECK: @p2 = weak local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), align 4
local char *p2;
-// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 8
-// COMMON: @p3 = common local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 8
+// CHECK: @p3 = common local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 8
constant char *p3;
-// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 8
-// COMMON: @p4 = common local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 8
+// CHECK: @p4 = common local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 8
global char *p4;
-// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8* null, align 8
-// COMMON: @p5 = common local_unnamed_addr addrspace(1) global i8* null, align 8
+// CHECK: @p5 = common local_unnamed_addr addrspace(1) global i8* null, align 8
generic char *p5;
// Test default initialization of structure.
-// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }, align 8
+// CHECK: @S1 = weak local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }, align 8
StructTy1 S1;
-// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 8
+// CHECK: @S2 = common local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 8
StructTy2 S2;
// Test default initialization of array.
-// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }, %struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }], align 8
+// CHECK: @A1 = weak local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }, %struct.StructTy1 { i8 addrspace(5)* null, i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), i8 addrspace(4)* null, i8 addrspace(1)* null, i8* null }], align 8
StructTy1 A1[2];
-// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 8
+// CHECK: @A2 = common local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 8
StructTy2 A2[2];
// Test comparison with 0.
diff --git a/clang/test/Driver/apple-kext-mkernel.c b/clang/test/Driver/apple-kext-mkernel.c
index f056ec898d4d..9c60c24e36c8 100644
--- a/clang/test/Driver/apple-kext-mkernel.c
+++ b/clang/test/Driver/apple-kext-mkernel.c
@@ -4,7 +4,7 @@
// CHECK-X86: "-disable-red-zone"
// CHECK-X86: "-fno-builtin"
// CHECK-X86: "-fno-rtti"
-// CHECK-X86-NOT: "-fcommon"
+// CHECK-X86: "-fno-common"
// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only -fbuiltin -fcommon %s 2>&1 | FileCheck --check-prefix=CHECK-X86-2 %s
@@ -21,7 +21,7 @@
// CHECK-ARM-NOT: "-target-feature" "+strict-align"
// CHECK-ARM: "-fno-builtin"
// CHECK-ARM: "-fno-rtti"
-// CHECK-ARM-NOT: "-fcommon"
+// CHECK-ARM: "-fno-common"
// RUN: %clang -target x86_64-apple-darwin10 \
// RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index bda026715c36..f628f5f40de3 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -12,7 +12,7 @@
// CHECK-OPTIONS2: -fno-gnu-keywords
// CHECK-OPTIONS2: -fno-builtin
// CHECK-OPTIONS2: -fshort-enums
-// CHECK-OPTIONS2-NOT: -fcommon
+// CHECK-OPTIONS2: -fno-common
// CHECK-OPTIONS2: -fno-show-source-location
// RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s
diff --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 5c1c00061d3a..185289defccd 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -22,7 +22,7 @@
// CHECK-AARCH64: "-fsanitize=shadow-call-stack"
// CHECK-X86_64: "-fsanitize=safe-stack"
// CHECK: "-stack-protector" "2"
-// CHECK-NOT: "-fcommon"
+// CHECK: "-fno-common"
// CHECK: {{.*}}ld.lld{{.*}}" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments"
// CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie"
diff --git a/clang/test/Driver/no-common.c b/clang/test/Driver/no-common.c
deleted file mode 100644
index 675de4fee8dc..000000000000
--- a/clang/test/Driver/no-common.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang -target %itanium_abi_triple -### -c %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=DEFAULT
-// RUN: %clang -target %itanium_abi_triple -fno-common -### -c %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=DEFAULT
-// RUN: %clang -target %itanium_abi_triple -fno-common -fcommon -### -c %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=COMMON
-
-// DEFAULT-NOT: "-fcommon"
-// COMMON: "-fcommon"
diff --git a/clang/test/Driver/xcore-opts.c b/clang/test/Driver/xcore-opts.c
index 8885974ec84a..2bf57967092a 100644
--- a/clang/test/Driver/xcore-opts.c
+++ b/clang/test/Driver/xcore-opts.c
@@ -9,7 +9,7 @@
// CHECK: "-fno-use-cxa-atexit"
// CHECK-NOT: "-fcxx-exceptions"
// CHECK-NOT: "-fexceptions"
-// CHECK-NOT: "-fcommon"
+// CHECK: "-fno-common"
// CHECK: xcc" "-o"
// CHECK-NOT: "-fexceptions"
// CHECK: "-c" "-v" "-g" "-fverbose-asm" "A1Arg" "A2Arg"
@@ -21,7 +21,7 @@
// CHECK-EXCEP: "-fno-use-cxa-atexit"
// CHECK-EXCEP: "-fcxx-exceptions"
// CHECK-EXCEP: "-fexceptions"
-// CHECK-EXCEP-NOT: "-fcommon"
+// CHECK-EXCEP: "-fno-common"
// CHECK-EXCEP: xcc" "-o"
// CHECK-EXCEP-NOT: "-fexceptions"
// CHECK-EXCEP: xcc" "-o"
diff --git a/clang/test/Frontend/ast-codegen.c b/clang/test/Frontend/ast-codegen.c
index b45377850a23..e1140fdd8b27 100644
--- a/clang/test/Frontend/ast-codegen.c
+++ b/clang/test/Frontend/ast-codegen.c
@@ -5,7 +5,7 @@
// CHECK: module asm "foo"
__asm__("foo");
-// CHECK: @g0 = dso_local global i32 0, align 4
+// CHECK: @g0 = common dso_local global i32 0, align 4
int g0;
// CHECK: define dso_local i32 @f0()
diff --git a/clang/test/Headers/xmmintrin.c b/clang/test/Headers/xmmintrin.c
index f0f832f81511..9b8993e6bb67 100644
--- a/clang/test/Headers/xmmintrin.c
+++ b/clang/test/Headers/xmmintrin.c
@@ -7,7 +7,7 @@
// REQUIRES: x86-registered-target
#include <xmmintrin.h>
-// CHECK: @c = global i8 0, align 16
+// CHECK: @c = common global i8 0, align 16
_MM_ALIGN16 char c;
// Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
diff --git a/clang/test/PCH/chain-external-defs.c b/clang/test/PCH/chain-external-defs.c
index a58c82c59c83..f7c723338996 100644
--- a/clang/test/PCH/chain-external-defs.c
+++ b/clang/test/PCH/chain-external-defs.c
@@ -16,11 +16,11 @@
// Z-NOT: @z
-// XA: @x = global i32 0
-// XA-NOT: @x = global i32 0
+// XA: @x = common global i32 0
+// XA-NOT: @x = common global i32 0
-// YA: @y = global i32 0
-// YA-NOT: @y = global i32 0
+// YA: @y = common global i32 0
+// YA-NOT: @y = common global i32 0
// XB: @x2 = global i32 19
// XB-NOT: @x2 = global i32 19
@@ -29,17 +29,17 @@ int x2 = 19;
// YB-NOT: @y2 = global i32 18
int y2 = 18;
-// AA: @incomplete_array = global [1 x i32]
-// AA-NOT: @incomplete_array = global [1 x i32]
-// AB: @incomplete_array2 = global [17 x i32]
-// AB-NOT: @incomplete_array2 = global [17 x i32]
+// AA: @incomplete_array = common global [1 x i32]
+// AA-NOT: @incomplete_array = common global [1 x i32]
+// AB: @incomplete_array2 = common global [17 x i32]
+// AB-NOT: @incomplete_array2 = common global [17 x i32]
int incomplete_array2[17];
-// AC: @incomplete_array3 = global [1 x i32]
-// AC-NOT: @incomplete_array3 = global [1 x i32]
+// AC: @incomplete_array3 = common global [1 x i32]
+// AC-NOT: @incomplete_array3 = common global [1 x i32]
int incomplete_array3[];
-// S: @s = global %struct.S
-// S-NOT: @s = global %struct.S
+// S: @s = common global %struct.S
+// S-NOT: @s = common global %struct.S
struct S {
int x, y;
};
diff --git a/clang/test/PCH/external-defs.c b/clang/test/PCH/external-defs.c
index e78125d61fdc..5e906b246bc7 100644
--- a/clang/test/PCH/external-defs.c
+++ b/clang/test/PCH/external-defs.c
@@ -3,16 +3,16 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
-// RUN: grep "@x = global i32 0" %t | count 1
+// RUN: grep "@x = common global i32 0" %t | count 1
// RUN: not grep "@z" %t
// RUN: grep "@x2 = global i32 19" %t | count 1
int x2 = 19;
-// RUN: grep "@incomplete_array = global .*1 x i32" %t | count 1
-// RUN: grep "@incomplete_array2 = global .*17 x i32" %t | count 1
+// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1
int incomplete_array2[17];
-// RUN: grep "@incomplete_array3 = global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1
int incomplete_array3[];
struct S {
diff --git a/clang/test/PCH/tentative-defs.c b/clang/test/PCH/tentative-defs.c
index f9fee0ca932e..7163316a93de 100644
--- a/clang/test/PCH/tentative-defs.c
+++ b/clang/test/PCH/tentative-defs.c
@@ -1,6 +1,6 @@
// Test with pch.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -emit-pch -o %t.pch %S/tentative-defs.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
// REQUIRES: x86-registered-target
// RUN: grep "@variable = common global i32 0" %t | count 1
diff --git a/clang/test/Parser/pragma-visibility2.c b/clang/test/Parser/pragma-visibility2.c
index 272294ca16ef..bcef09ff2b99 100644
--- a/clang/test/Parser/pragma-visibility2.c
+++ b/clang/test/Parser/pragma-visibility2.c
@@ -6,14 +6,14 @@
#pragma GCC visibility push(hidden)
int v1;
-// CHECK: @v1 = hidden global i32 0, align 4
+// CHECK: @v1 = common hidden global i32 0, align 4
#pragma GCC visibility pop
int v2;
-// CHECK: @v2 = global i32 0, align 4
+// CHECK: @v2 = common global i32 0, align 4
_Pragma("GCC visibility push(hidden)");
int v3;
-// CHECK: @v3 = hidden global i32 0, align 4
+// CHECK: @v3 = common hidden global i32 0, align 4
More information about the cfe-commits
mailing list