Skip to content

Commit 0a9fc92

Browse files
author
Sjoerd Meijer
committed
[Driver] Default to -fno-common for all targets
This makes -fno-common the default for all targets because this has performance and code-size benefits and is more language conforming for C code. Additionally, GCC10 also defaults to -fno-common and so we get consistent behaviour with GCC. With this change, 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. As GCC has switched already, we benefit from applications already being ported and existing documentation how to do this. For example: - https://gcc.gnu.org/gcc-10/porting_to.html - https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common Differential revision: https://reviews.llvm.org/D75056
1 parent d58e383 commit 0a9fc92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+157
-146
lines changed

clang/docs/ClangCommandLineReference.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,10 @@ Use colors in diagnostics
13071307

13081308
.. option:: -fcommon, -fno-common
13091309

1310+
Place definitions of variables with no storage class and no initializer
1311+
(tentative definitions) in a common block, instead of generating individual
1312+
zero-initialized definitions (default -fno-common).
1313+
13101314
.. option:: -fcompile-resource=<arg>, --resource <arg>, --resource=<arg>
13111315

13121316
.. option:: -fconstant-cfstrings, -fno-constant-cfstrings

clang/docs/ReleaseNotes.rst

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ future versions of Clang.
8484
Modified Compiler Flags
8585
-----------------------
8686

87+
- -fno-common has been enabled as the default for all targets. Therefore, C
88+
code that uses tentative definitions as definitions of a variable in multiple
89+
translation units will trigger multiple-definition linker errors. Generally,
90+
this occurs when the use of the ``extern`` keyword is neglected in the declaration
91+
of a variable in a header file. In some cases, no specific translation unit
92+
provides a definition of the variable. The previous behavior can be restored by
93+
specifying ``-fcommon``.
8794

8895
New Pragmas in Clang
8996
--------------------

clang/include/clang/Driver/Options.td

+2-1
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@ def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
848848
Group<f_clang_Group>;
849849
def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
850850
def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
851-
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>;
851+
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
852+
Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">;
852853
def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group<f_Group>;
853854
def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group<f_clang_Group>,
854855
Flags<[CoreOption, CC1Option]>,

clang/lib/Driver/ToolChains/Clang.cpp

+3-19
Original file line numberDiff line numberDiff line change
@@ -1408,20 +1408,6 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
14081408
}
14091409
}
14101410

1411-
static bool isNoCommonDefault(const llvm::Triple &Triple) {
1412-
switch (Triple.getArch()) {
1413-
default:
1414-
if (Triple.isOSFuchsia())
1415-
return true;
1416-
return false;
1417-
1418-
case llvm::Triple::xcore:
1419-
case llvm::Triple::wasm32:
1420-
case llvm::Triple::wasm64:
1421-
return true;
1422-
}
1423-
}
1424-
14251411
static bool hasMultipleInvocations(const llvm::Triple &Triple,
14261412
const ArgList &Args) {
14271413
// Supported only on Darwin where we invoke the compiler multiple times
@@ -5675,11 +5661,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56755661
if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
56765662
CmdArgs.push_back("-Qn");
56775663

5678-
// -fcommon is the default unless compiling kernel code or the target says so
5679-
bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple);
5680-
if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common,
5681-
!NoCommonDefault))
5682-
CmdArgs.push_back("-fno-common");
5664+
// -fno-common is the default, set -fcommon only when that flag is set.
5665+
if (Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, false))
5666+
CmdArgs.push_back("-fcommon");
56835667

56845668
// -fsigned-bitfields is default, and clang doesn't yet support
56855669
// -funsigned-bitfields.

clang/lib/Frontend/CompilerInvocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
809809
Opts.RecordCommandLine =
810810
std::string(Args.getLastArgValue(OPT_record_command_line));
811811
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
812-
Opts.NoCommon = Args.hasArg(OPT_fno_common);
812+
Opts.NoCommon = !Args.hasArg(OPT_fcommon);
813813
Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
814814
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
815815
Opts.OptimizeSize = getOptimizationLevelSize(Args);

clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
int g0, f0();
44
int f1(), g1;
55

6-
// CHECK: @g0 = common {{(dso_local )?}}global i32 0, align 4
7-
// CHECK: @g1 = common {{(dso_local )?}}global i32 0, align 4
6+
// CHECK: @g0 = {{(dso_local )?}}global i32 0, align 4
7+
// CHECK: @g1 = {{(dso_local )?}}global i32 0, align 4
88

clang/test/CodeGen/2009-10-20-GlobalDebug.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s
33

44
// CHECK: @main.localstatic = internal global i32 0, align 4, !dbg [[L:![0-9]+]]
5-
// CHECK: @global = common global i32 0, align 4, !dbg [[G:![0-9]+]]
5+
// CHECK: @global = global i32 0, align 4, !dbg [[G:![0-9]+]]
66

77
int global;
8-
int main() {
8+
int main() {
99
static int localstatic;
1010
return 0;
1111
}

clang/test/CodeGen/aarch64-sve.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat64_t'
1717
// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
1818

19-
// CHECK: @ptr = common global <vscale x 16 x i8>* null, align 8
19+
// CHECK: @ptr = global <vscale x 16 x i8>* null, align 8
2020
// CHECK: %s8 = alloca <vscale x 16 x i8>, align 16
2121
// CHECK: %s16 = alloca <vscale x 8 x i16>, align 16
2222
// CHECK: %s32 = alloca <vscale x 4 x i32>, align 16

clang/test/CodeGen/address-space.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,X86 %s
22
// RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,AMDGCN %s
33

4-
// CHECK: @foo = common addrspace(1) global
4+
// CHECK: @foo = addrspace(1) global
55
int foo __attribute__((address_space(1)));
66

7-
// CHECK: @ban = common addrspace(1) global
7+
// CHECK: @ban = addrspace(1) global
88
int ban[10] __attribute__((address_space(1)));
99

10-
// CHECK: @a = common global
10+
// CHECK: @a = global
1111
int a __attribute__((address_space(0)));
1212

1313
// CHECK-LABEL: define i32 @test1()

clang/test/CodeGen/alias.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
66

77
int g0;
8-
// CHECKBASIC-DAG: @g0 = common global i32 0
9-
// CHECKASM-DAG: .comm g0,4,4
8+
// CHECKBASIC-DAG: @g0 = global i32 0
9+
// CHECKASM-DAG: .bss
10+
// CHECKASM-DAG: .globl g0
11+
// CHECKASM-DAG: .p2align 2
12+
// CHECKASM-DAG: g0:
13+
// CHECKASM-DAG: .long 0
14+
// CHECKASM-DAG: .size g0, 4
1015
__thread int TL_WITH_ALIAS;
1116
// CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4
1217
// CHECKASM-DAG: .globl TL_WITH_ALIAS

clang/test/CodeGen/align-systemz.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ struct test {
77
};
88

99
char c;
10-
// CHECK-DAG: @c = common global i8 0, align 2
10+
// CHECK-DAG: @c = global i8 0, align 2
1111

1212
struct test s;
13-
// CHECK-DAG: @s = common global %struct.test zeroinitializer, align 2
13+
// CHECK-DAG: @s = global %struct.test zeroinitializer, align 2
1414

1515
extern char ec;
1616
// CHECK-DAG: @ec = external global i8, align 2

clang/test/CodeGen/alignment.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ union {int a[4]; __attribute((aligned(16))) float b[4];} b;
77
// CHECK: @b = {{.*}}zeroinitializer, align 16
88

99
long long int test5[1024];
10-
// CHECK-DAG: @test5 = common global [1024 x i64] zeroinitializer, align 8
10+
// CHECK-DAG: @test5 = global [1024 x i64] zeroinitializer, align 8
1111

1212
// PR5279 - Reduced alignment on typedef.
1313
typedef int myint __attribute__((aligned(1)));

clang/test/CodeGen/asm-label.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ int *test(void) {
1111
}
1212

1313
// LINUX: @bar = internal global i32 0
14-
// LINUX: @foo = common global i32 0
14+
// LINUX: @foo = global i32 0
1515
// LINUX: declare i8* @alias(i32)
1616

1717
// DARWIN: @"\01bar" = internal global i32 0
18-
// DARWIN: @"\01foo" = common global i32 0
18+
// DARWIN: @"\01foo" = global i32 0
1919
// DARWIN: declare i8* @"\01alias"(i32)

clang/test/CodeGen/attr-weak-import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern int E __attribute__((weak_import));
2020

2121
// CHECK: @A = global i32
2222
// CHECK-NOT: @B =
23-
// CHECK: @C = common global i32
23+
// CHECK: @C = global i32
2424
// CHECK: @D = global i32
2525
// CHECK: @E = global i32
2626

clang/test/CodeGen/attr-weakref2.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int test1_h(void) {
88
return test1_g;
99
}
1010

11-
// CHECK: @test2_f = common global i32 0, align 4
11+
// CHECK: @test2_f = global i32 0, align 4
1212
int test2_f;
1313
static int test2_g __attribute__((weakref("test2_f")));
1414
int test2_h(void) {
@@ -25,7 +25,7 @@ int test3_h(void) {
2525
return test3_g;
2626
}
2727

28-
// CHECK: @test4_f = common global i32 0, align 4
28+
// CHECK: @test4_f = global i32 0, align 4
2929
extern int test4_f;
3030
static int test4_g __attribute__((weakref("test4_f")));
3131
int test4_h(void) {

clang/test/CodeGen/attributes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int t18 = 1;
2020
// CHECK: @t16 = extern_weak global i32
2121
extern int t16 __attribute__((weak_import));
2222

23-
// CHECK: @t6 = common protected global i32 0
23+
// CHECK: @t6 = protected global i32 0
2424
int t6 __attribute__((visibility("protected")));
2525

2626
// CHECK: @t12 = global i32 0, section "SECT"

clang/test/CodeGen/blocks-windows.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int (*g(void))(void) {
6868
}
6969

7070
// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local dllexport global i8*
71-
// CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local dllexport global [5 x i32]
71+
// CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = dso_local dllexport global [5 x i32]
7272
// CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport global i8*
7373
// CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN: @_NSConcreteStackBlock = external dllimport global i8*
7474
// CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN-DLLIMPORT: @_NSConcreteStackBlock = external dllimport global i8*

clang/test/CodeGen/bool-convert.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// All of these should uses the memory representation of _Bool
33

44
// CHECK-LABEL: %struct.teststruct1 = type { i8, i8 }
5-
// CHECK-LABEL: @test1 = common global %struct.teststruct1
5+
// CHECK-LABEL: @test1 = global %struct.teststruct1
66
struct teststruct1 {_Bool a, b;} test1;
77

8-
// CHECK-LABEL: @test2 = common global i8* null
8+
// CHECK-LABEL: @test2 = global i8* null
99
_Bool* test2;
1010

11-
// CHECK-LABEL: @test3 = common global [10 x i8]
11+
// CHECK-LABEL: @test3 = global [10 x i8]
1212
_Bool test3[10];
1313

14-
// CHECK-LABEL: @test4 = common global [0 x i8]* null
14+
// CHECK-LABEL: @test4 = global [0 x i8]* null
1515
_Bool (*test4)[];
1616

1717
// CHECK-LABEL: define void @f(i32 %x)

clang/test/CodeGen/c11atomics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct elem {
2525
// CHECK-DAG: %struct.elem = type { %struct.ptr }
2626

2727
struct ptr object;
28-
// CHECK-DAG: @object = common global %struct.ptr zeroinitializer
28+
// CHECK-DAG: @object = global %struct.ptr zeroinitializer
2929

3030
// CHECK-DAG: @testStructGlobal = global {{.*}} { i16 1, i16 2, i16 3, i16 4 }
3131
// CHECK-DAG: @testPromotedStructGlobal = global {{.*}} { %{{.*}} { i16 1, i16 2, i16 3 }, [2 x i8] zeroinitializer }

clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("
3030

3131

3232
// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external global [0 x i32]
33-
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common global [32 x i64] zeroinitializer, align 16
34-
// CHECK-CF: @__CFConstantStringClassReference = common global [1 x i64] zeroinitializer, align 8
33+
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = global [32 x i64] zeroinitializer, align 16
34+
// CHECK-CF: @__CFConstantStringClassReference = global [1 x i64] zeroinitializer, align 8
3535
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external global [0 x i32]
3636
// CHECK-CF-EXTERN: @.str = private unnamed_addr constant [7 x i8] c"string\00", section ".rodata", align 1

clang/test/CodeGen/cfstring-windows.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef struct __CFString *CFStringRef;
3232
const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("string");
3333

3434
// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external dso_local dllexport global [0 x i32]
35-
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common dso_local dllexport global [32 x i32]
35+
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = dso_local dllexport global [32 x i32]
3636
// CHECK-CF: @__CFConstantStringClassReference = external dllimport global [0 x i32]
3737
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external dllimport global [0 x i32]
3838
// CHECK-CF-EXTERN-DLLIMPORT: @__CFConstantStringClassReference = external dllimport global [0 x i32]

clang/test/CodeGen/default-address-space.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s
22

3-
// CHECK-DAG: @foo = common addrspace(1) global i32 0
3+
// CHECK-DAG: @foo = addrspace(1) global i32 0
44
int foo;
55

6-
// CHECK-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer
6+
// CHECK-DAG: @ban = addrspace(1) global [10 x i32] zeroinitializer
77
int ban[10];
88

9-
// CHECK-DAG: @A = common addrspace(1) global i32* null
10-
// CHECK-DAG: @B = common addrspace(1) global i32* null
9+
// CHECK-DAG: @A = addrspace(1) global i32* null
10+
// CHECK-DAG: @B = addrspace(1) global i32* null
1111
int *A;
1212
int *B;
1313

clang/test/CodeGen/dllexport-1.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// CHECK-MSVC: @z = dso_local constant i32 4, align 4
1010
// CHECK-LNX: @z = constant i32 4, align 4
1111

12-
// CHECK-MSVC: @y = common dso_local dllexport global i32 0, align 4
13-
// CHECK-LNX: @y = common global i32 0, align 4
12+
// CHECK-MSVC: @y = dso_local dllexport constant i32 0, align 4
13+
// CHECK-LNX: @y = constant i32 0, align 4
1414

1515
__declspec(dllexport) int const x = 3;
1616
__declspec(dllexport) const int y;

clang/test/CodeGen/dllexport.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
__declspec(dllexport) extern int ExternGlobalDecl;
1515

1616
// dllexport implies a definition.
17-
// CHECK-DAG: @GlobalDef = common dso_local dllexport global i32 0, align 4
17+
// CHECK-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
1818
__declspec(dllexport) int GlobalDef;
1919

2020
// Export definition.
@@ -27,11 +27,11 @@ __declspec(dllexport) extern int GlobalDeclInit;
2727
int GlobalDeclInit = 1;
2828

2929
// Redeclarations
30-
// CHECK-DAG: @GlobalRedecl1 = common dso_local dllexport global i32 0, align 4
30+
// CHECK-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
3131
__declspec(dllexport) extern int GlobalRedecl1;
3232
__declspec(dllexport) int GlobalRedecl1;
3333

34-
// CHECK-DAG: @GlobalRedecl2 = common dso_local dllexport global i32 0, align 4
34+
// CHECK-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
3535
__declspec(dllexport) extern int GlobalRedecl2;
3636
int GlobalRedecl2;
3737

@@ -70,29 +70,29 @@ __declspec(dllexport) void redecl2(void);
7070
//===----------------------------------------------------------------------===//
7171

7272
// dllexport takes precedence over the dllimport if both are specified.
73-
// CHECK-DAG: @PrecedenceGlobal1A = common dso_local dllexport global i32 0, align 4
74-
// CHECK-DAG: @PrecedenceGlobal1B = common dso_local dllexport global i32 0, align 4
73+
// CHECK-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
74+
// CHECK-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
7575
__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A;
7676
__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B;
7777

78-
// CHECK-DAG: @PrecedenceGlobal2A = common dso_local dllexport global i32 0, align 4
79-
// CHECK-DAG: @PrecedenceGlobal2B = common dso_local dllexport global i32 0, align 4
78+
// CHECK-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
79+
// CHECK-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
8080
__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A;
8181
__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
8282

8383
// CHECK-DAG: @PrecedenceGlobalRedecl1 = dso_local dllexport global i32 0, align 4
8484
__declspec(dllexport) extern int PrecedenceGlobalRedecl1;
8585
__declspec(dllimport) int PrecedenceGlobalRedecl1 = 0;
8686

87-
// CHECK-DAG: @PrecedenceGlobalRedecl2 = common dso_local dllexport global i32 0, align 4
87+
// CHECK-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
8888
__declspec(dllimport) extern int PrecedenceGlobalRedecl2;
8989
__declspec(dllexport) int PrecedenceGlobalRedecl2;
9090

9191
// CHECK-DAG: @PrecedenceGlobalMixed1 = dso_local dllexport global i32 1, align 4
9292
__attribute__((dllexport)) extern int PrecedenceGlobalMixed1;
9393
__declspec(dllimport) int PrecedenceGlobalMixed1 = 1;
9494

95-
// CHECK-DAG: @PrecedenceGlobalMixed2 = common dso_local dllexport global i32 0, align 4
95+
// CHECK-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
9696
__attribute__((dllimport)) extern int PrecedenceGlobalMixed2;
9797
__declspec(dllexport) int PrecedenceGlobalMixed2;
9898

clang/test/CodeGen/dllimport.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ __declspec(dllimport) extern int GlobalRedecl3;
4646
USEVAR(GlobalRedecl3)
4747

4848
// Make sure this works even if the decl has been used before it's defined (PR20792).
49-
// MS: @GlobalRedecl4 = common dso_local dllexport global i32
50-
// GNU: @GlobalRedecl4 = common dso_local global i32
49+
// MS: @GlobalRedecl4 = dso_local dllexport global i32
50+
// GNU: @GlobalRedecl4 = dso_local global i32
5151
__declspec(dllimport) extern int GlobalRedecl4;
5252
USEVAR(GlobalRedecl4)
5353
int GlobalRedecl4; // dllimport ignored

clang/test/CodeGen/microsoft-no-common-align.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fcommon -emit-llvm -o - %s | FileCheck %s
22
typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
33
typedef float NormalAlignment __attribute__((__vector_size__(4)));
44

clang/test/CodeGen/no-common.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
2-
// RUN: %clang_cc1 %s -fno-common -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-NOCOMMON
2+
// RUN: %clang_cc1 %s -fno-common -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
3+
// RUN: %clang_cc1 %s -fcommon -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-COMMON
34

4-
// CHECK-DEFAULT: @x = common {{(dso_local )?}}global
5-
// CHECK-NOCOMMON: @x = {{(dso_local )?}}global
5+
// CHECK-COMMON: @x = common {{(dso_local )?}}global
6+
// CHECK-DEFAULT: @x = {{(dso_local )?}}global
67
int x;
78

9+
// CHECK-COMMON: @ABC = {{(dso_local )?}}global
810
// CHECK-DEFAULT: @ABC = {{(dso_local )?}}global
9-
// CHECK-NOCOMMON: @ABC = {{(dso_local )?}}global
1011
typedef void* (*fn_t)(long a, long b, char *f, int c);
1112
fn_t ABC __attribute__ ((nocommon));
1213

14+
// CHECK-COMMON: @y = common {{(dso_local )?}}global
1315
// CHECK-DEFAULT: @y = common {{(dso_local )?}}global
14-
// CHECK-NOCOMMON: @y = common {{(dso_local )?}}global
1516
int y __attribute__((common));

0 commit comments

Comments
 (0)