Recommit #2 "[Driver] Default to -fno-common for all targets"

After a first attempt to fix the test-suite failures, my first recommit
caused the same failures again. I had updated CMakeList.txt files of
tests that needed -fcommon, but it turns out that there are also
Makefiles which are used by some bots, so I've updated these Makefiles
now too.

See the original commit message for more details on this change:
0a9fc9233e
This commit is contained in:
Sjoerd Meijer 2020-03-09 19:25:24 +00:00
parent 156a1b59df
commit 3d9a0445cc
57 changed files with 164 additions and 152 deletions

View File

@ -1307,6 +1307,10 @@ Use colors in diagnostics
.. option:: -fcommon, -fno-common .. 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:: -fcompile-resource=<arg>, --resource <arg>, --resource=<arg>
.. option:: -fconstant-cfstrings, -fno-constant-cfstrings .. option:: -fconstant-cfstrings, -fno-constant-cfstrings

View File

@ -84,6 +84,13 @@ future versions of Clang.
Modified Compiler Flags 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 New Pragmas in Clang
-------------------- --------------------

View File

@ -848,7 +848,8 @@ def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
Group<f_clang_Group>; Group<f_clang_Group>;
def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>; def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>; def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>; def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">;
def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, 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>, def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group<f_clang_Group>,
Flags<[CoreOption, CC1Option]>, Flags<[CoreOption, CC1Option]>,

View File

@ -1408,20 +1408,6 @@ 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, static bool hasMultipleInvocations(const llvm::Triple &Triple,
const ArgList &Args) { const ArgList &Args) {
// Supported only on Darwin where we invoke the compiler multiple times // Supported only on Darwin where we invoke the compiler multiple times
@ -5692,11 +5678,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true)) if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
CmdArgs.push_back("-Qn"); CmdArgs.push_back("-Qn");
// -fcommon is the default unless compiling kernel code or the target says so // -fno-common is the default, set -fcommon only when that flag is set.
bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple); if (Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, false))
if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, CmdArgs.push_back("-fcommon");
!NoCommonDefault))
CmdArgs.push_back("-fno-common");
// -fsigned-bitfields is default, and clang doesn't yet support // -fsigned-bitfields is default, and clang doesn't yet support
// -funsigned-bitfields. // -funsigned-bitfields.

View File

@ -811,7 +811,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.RecordCommandLine = Opts.RecordCommandLine =
std::string(Args.getLastArgValue(OPT_record_command_line)); std::string(Args.getLastArgValue(OPT_record_command_line));
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants); Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
Opts.NoCommon = Args.hasArg(OPT_fno_common); Opts.NoCommon = !Args.hasArg(OPT_fcommon);
Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables); Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float); Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Opts.OptimizeSize = getOptimizationLevelSize(Args); Opts.OptimizeSize = getOptimizationLevelSize(Args);

View File

@ -3,6 +3,6 @@
int g0, f0(); int g0, f0();
int f1(), g1; int f1(), g1;
// CHECK: @g0 = common {{(dso_local )?}}global i32 0, align 4 // CHECK: @g0 = {{(dso_local )?}}global i32 0, align 4
// CHECK: @g1 = common {{(dso_local )?}}global i32 0, align 4 // CHECK: @g1 = {{(dso_local )?}}global i32 0, align 4

View File

@ -2,10 +2,10 @@
// RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s // 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: @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 global;
int main() { int main() {
static int localstatic; static int localstatic;
return 0; return 0;
} }

View File

@ -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 '__SVFloat64_t'
// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t' // CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
// CHECK: @ptr = common global <vscale x 16 x i8>* null, align 8 // CHECK: @ptr = global <vscale x 16 x i8>* null, align 8
// CHECK: %s8 = alloca <vscale x 16 x i8>, align 16 // CHECK: %s8 = alloca <vscale x 16 x i8>, align 16
// CHECK: %s16 = alloca <vscale x 8 x i16>, align 16 // CHECK: %s16 = alloca <vscale x 8 x i16>, align 16
// CHECK: %s32 = alloca <vscale x 4 x i32>, align 16 // CHECK: %s32 = alloca <vscale x 4 x i32>, align 16

View File

@ -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 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 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,AMDGCN %s
// CHECK: @foo = common addrspace(1) global // CHECK: @foo = addrspace(1) global
int foo __attribute__((address_space(1))); int foo __attribute__((address_space(1)));
// CHECK: @ban = common addrspace(1) global // CHECK: @ban = addrspace(1) global
int ban[10] __attribute__((address_space(1))); int ban[10] __attribute__((address_space(1)));
// CHECK: @a = common global // CHECK: @a = global
int a __attribute__((address_space(0))); int a __attribute__((address_space(0)));
// CHECK-LABEL: define i32 @test1() // CHECK-LABEL: define i32 @test1()

View File

@ -5,8 +5,13 @@
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
int g0; int g0;
// CHECKBASIC-DAG: @g0 = common global i32 0 // CHECKBASIC-DAG: @g0 = global i32 0
// CHECKASM-DAG: .comm g0,4,4 // CHECKASM-DAG: .bss
// CHECKASM-DAG: .globl g0
// CHECKASM-DAG: .p2align 2
// CHECKASM-DAG: g0:
// CHECKASM-DAG: .long 0
// CHECKASM-DAG: .size g0, 4
__thread int TL_WITH_ALIAS; __thread int TL_WITH_ALIAS;
// CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4 // CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4
// CHECKASM-DAG: .globl TL_WITH_ALIAS // CHECKASM-DAG: .globl TL_WITH_ALIAS

View File

@ -7,10 +7,10 @@ struct test {
}; };
char c; char c;
// CHECK-DAG: @c = common global i8 0, align 2 // CHECK-DAG: @c = global i8 0, align 2
struct test s; struct test s;
// CHECK-DAG: @s = common global %struct.test zeroinitializer, align 2 // CHECK-DAG: @s = global %struct.test zeroinitializer, align 2
extern char ec; extern char ec;
// CHECK-DAG: @ec = external global i8, align 2 // CHECK-DAG: @ec = external global i8, align 2

View File

@ -7,7 +7,7 @@ union {int a[4]; __attribute((aligned(16))) float b[4];} b;
// CHECK: @b = {{.*}}zeroinitializer, align 16 // CHECK: @b = {{.*}}zeroinitializer, align 16
long long int test5[1024]; long long int test5[1024];
// CHECK-DAG: @test5 = common global [1024 x i64] zeroinitializer, align 8 // CHECK-DAG: @test5 = global [1024 x i64] zeroinitializer, align 8
// PR5279 - Reduced alignment on typedef. // PR5279 - Reduced alignment on typedef.
typedef int myint __attribute__((aligned(1))); typedef int myint __attribute__((aligned(1)));

View File

@ -11,9 +11,9 @@ int *test(void) {
} }
// LINUX: @bar = internal global i32 0 // LINUX: @bar = internal global i32 0
// LINUX: @foo = common global i32 0 // LINUX: @foo = global i32 0
// LINUX: declare i8* @alias(i32) // LINUX: declare i8* @alias(i32)
// DARWIN: @"\01bar" = internal global i32 0 // DARWIN: @"\01bar" = internal global i32 0
// DARWIN: @"\01foo" = common global i32 0 // DARWIN: @"\01foo" = global i32 0
// DARWIN: declare i8* @"\01alias"(i32) // DARWIN: declare i8* @"\01alias"(i32)

View File

@ -20,7 +20,7 @@ extern int E __attribute__((weak_import));
// CHECK: @A = global i32 // CHECK: @A = global i32
// CHECK-NOT: @B = // CHECK-NOT: @B =
// CHECK: @C = common global i32 // CHECK: @C = global i32
// CHECK: @D = global i32 // CHECK: @D = global i32
// CHECK: @E = global i32 // CHECK: @E = global i32

View File

@ -8,7 +8,7 @@ int test1_h(void) {
return test1_g; return test1_g;
} }
// CHECK: @test2_f = common global i32 0, align 4 // CHECK: @test2_f = global i32 0, align 4
int test2_f; int test2_f;
static int test2_g __attribute__((weakref("test2_f"))); static int test2_g __attribute__((weakref("test2_f")));
int test2_h(void) { int test2_h(void) {
@ -25,7 +25,7 @@ int test3_h(void) {
return test3_g; return test3_g;
} }
// CHECK: @test4_f = common global i32 0, align 4 // CHECK: @test4_f = global i32 0, align 4
extern int test4_f; extern int test4_f;
static int test4_g __attribute__((weakref("test4_f"))); static int test4_g __attribute__((weakref("test4_f")));
int test4_h(void) { int test4_h(void) {

View File

@ -20,7 +20,7 @@ int t18 = 1;
// CHECK: @t16 = extern_weak global i32 // CHECK: @t16 = extern_weak global i32
extern int t16 __attribute__((weak_import)); extern int t16 __attribute__((weak_import));
// CHECK: @t6 = common protected global i32 0 // CHECK: @t6 = protected global i32 0
int t6 __attribute__((visibility("protected"))); int t6 __attribute__((visibility("protected")));
// CHECK: @t12 = global i32 0, section "SECT" // CHECK: @t12 = global i32 0, section "SECT"

View File

@ -68,7 +68,7 @@ int (*g(void))(void) {
} }
// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local dllexport global i8* // CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local dllexport global i8*
// CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local dllexport global [5 x i32] // CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = dso_local dllexport global [5 x i32]
// CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport global i8* // 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: @_NSConcreteStackBlock = external dllimport global i8*
// CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN-DLLIMPORT: @_NSConcreteStackBlock = external dllimport global i8* // CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN-DLLIMPORT: @_NSConcreteStackBlock = external dllimport global i8*

View File

@ -2,16 +2,16 @@
// All of these should uses the memory representation of _Bool // All of these should uses the memory representation of _Bool
// CHECK-LABEL: %struct.teststruct1 = type { i8, i8 } // CHECK-LABEL: %struct.teststruct1 = type { i8, i8 }
// CHECK-LABEL: @test1 = common global %struct.teststruct1 // CHECK-LABEL: @test1 = global %struct.teststruct1
struct teststruct1 {_Bool a, b;} test1; struct teststruct1 {_Bool a, b;} test1;
// CHECK-LABEL: @test2 = common global i8* null // CHECK-LABEL: @test2 = global i8* null
_Bool* test2; _Bool* test2;
// CHECK-LABEL: @test3 = common global [10 x i8] // CHECK-LABEL: @test3 = global [10 x i8]
_Bool test3[10]; _Bool test3[10];
// CHECK-LABEL: @test4 = common global [0 x i8]* null // CHECK-LABEL: @test4 = global [0 x i8]* null
_Bool (*test4)[]; _Bool (*test4)[];
// CHECK-LABEL: define void @f(i32 %x) // CHECK-LABEL: define void @f(i32 %x)

View File

@ -25,7 +25,7 @@ struct elem {
// CHECK-DAG: %struct.elem = type { %struct.ptr } // CHECK-DAG: %struct.elem = type { %struct.ptr }
struct ptr object; struct ptr object;
// CHECK-DAG: @object = common global %struct.ptr zeroinitializer // CHECK-DAG: @object = global %struct.ptr zeroinitializer
// CHECK-DAG: @testStructGlobal = global {{.*}} { i16 1, i16 2, i16 3, i16 4 } // 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 } // CHECK-DAG: @testPromotedStructGlobal = global {{.*}} { %{{.*}} { i16 1, i16 2, i16 3 }, [2 x i8] zeroinitializer }

View File

@ -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-DECL: @__CFConstantStringClassReference = external global [0 x i32]
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common global [32 x i64] zeroinitializer, align 16 // CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = global [32 x i64] zeroinitializer, align 16
// CHECK-CF: @__CFConstantStringClassReference = common global [1 x i64] zeroinitializer, align 8 // CHECK-CF: @__CFConstantStringClassReference = global [1 x i64] zeroinitializer, align 8
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external global [0 x i32] // 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 // CHECK-CF-EXTERN: @.str = private unnamed_addr constant [7 x i8] c"string\00", section ".rodata", align 1

View File

@ -32,7 +32,7 @@ typedef struct __CFString *CFStringRef;
const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("string"); 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-DECL: @__CFConstantStringClassReference = external dso_local dllexport global [0 x i32]
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common dso_local dllexport global [32 x i32] // CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = dso_local dllexport global [32 x i32]
// CHECK-CF: @__CFConstantStringClassReference = external dllimport global [0 x i32] // CHECK-CF: @__CFConstantStringClassReference = external dllimport global [0 x i32]
// CHECK-CF-EXTERN: @__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] // CHECK-CF-EXTERN-DLLIMPORT: @__CFConstantStringClassReference = external dllimport global [0 x i32]

View File

@ -1,13 +1,13 @@
// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s // RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s
// CHECK-DAG: @foo = common addrspace(1) global i32 0 // CHECK-DAG: @foo = addrspace(1) global i32 0
int foo; int foo;
// CHECK-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer // CHECK-DAG: @ban = addrspace(1) global [10 x i32] zeroinitializer
int ban[10]; int ban[10];
// CHECK-DAG: @A = common addrspace(1) global i32* null // CHECK-DAG: @A = addrspace(1) global i32* null
// CHECK-DAG: @B = common addrspace(1) global i32* null // CHECK-DAG: @B = addrspace(1) global i32* null
int *A; int *A;
int *B; int *B;

View File

@ -9,8 +9,8 @@
// CHECK-MSVC: @z = dso_local constant i32 4, align 4 // CHECK-MSVC: @z = dso_local constant i32 4, align 4
// CHECK-LNX: @z = constant i32 4, align 4 // CHECK-LNX: @z = constant i32 4, align 4
// CHECK-MSVC: @y = common dso_local dllexport global i32 0, align 4 // CHECK-MSVC: @y = dso_local dllexport constant i32 0, align 4
// CHECK-LNX: @y = common global i32 0, align 4 // CHECK-LNX: @y = constant i32 0, align 4
__declspec(dllexport) int const x = 3; __declspec(dllexport) int const x = 3;
__declspec(dllexport) const int y; __declspec(dllexport) const int y;

View File

@ -14,7 +14,7 @@
__declspec(dllexport) extern int ExternGlobalDecl; __declspec(dllexport) extern int ExternGlobalDecl;
// dllexport implies a definition. // dllexport implies a definition.
// CHECK-DAG: @GlobalDef = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
__declspec(dllexport) int GlobalDef; __declspec(dllexport) int GlobalDef;
// Export definition. // Export definition.
@ -27,11 +27,11 @@ __declspec(dllexport) extern int GlobalDeclInit;
int GlobalDeclInit = 1; int GlobalDeclInit = 1;
// Redeclarations // Redeclarations
// CHECK-DAG: @GlobalRedecl1 = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
__declspec(dllexport) extern int GlobalRedecl1; __declspec(dllexport) extern int GlobalRedecl1;
__declspec(dllexport) int GlobalRedecl1; __declspec(dllexport) int GlobalRedecl1;
// CHECK-DAG: @GlobalRedecl2 = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
__declspec(dllexport) extern int GlobalRedecl2; __declspec(dllexport) extern int GlobalRedecl2;
int GlobalRedecl2; int GlobalRedecl2;
@ -70,13 +70,13 @@ __declspec(dllexport) void redecl2(void);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// dllexport takes precedence over the dllimport if both are specified. // dllexport takes precedence over the dllimport if both are specified.
// CHECK-DAG: @PrecedenceGlobal1A = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
// CHECK-DAG: @PrecedenceGlobal1B = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A; __attribute__((dllimport, dllexport)) int PrecedenceGlobal1A;
__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; __declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B;
// CHECK-DAG: @PrecedenceGlobal2A = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
// CHECK-DAG: @PrecedenceGlobal2B = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A; __attribute__((dllexport, dllimport)) int PrecedenceGlobal2A;
__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
@ -84,7 +84,7 @@ __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
__declspec(dllexport) extern int PrecedenceGlobalRedecl1; __declspec(dllexport) extern int PrecedenceGlobalRedecl1;
__declspec(dllimport) int PrecedenceGlobalRedecl1 = 0; __declspec(dllimport) int PrecedenceGlobalRedecl1 = 0;
// CHECK-DAG: @PrecedenceGlobalRedecl2 = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
__declspec(dllimport) extern int PrecedenceGlobalRedecl2; __declspec(dllimport) extern int PrecedenceGlobalRedecl2;
__declspec(dllexport) int PrecedenceGlobalRedecl2; __declspec(dllexport) int PrecedenceGlobalRedecl2;
@ -92,7 +92,7 @@ __declspec(dllexport) int PrecedenceGlobalRedecl2;
__attribute__((dllexport)) extern int PrecedenceGlobalMixed1; __attribute__((dllexport)) extern int PrecedenceGlobalMixed1;
__declspec(dllimport) int PrecedenceGlobalMixed1 = 1; __declspec(dllimport) int PrecedenceGlobalMixed1 = 1;
// CHECK-DAG: @PrecedenceGlobalMixed2 = common dso_local dllexport global i32 0, align 4 // CHECK-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
__attribute__((dllimport)) extern int PrecedenceGlobalMixed2; __attribute__((dllimport)) extern int PrecedenceGlobalMixed2;
__declspec(dllexport) int PrecedenceGlobalMixed2; __declspec(dllexport) int PrecedenceGlobalMixed2;

View File

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

View File

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

View File

@ -1,15 +1,16 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT // 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-NOCOMMON // 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
// CHECK-DEFAULT: @x = common {{(dso_local )?}}global // CHECK-COMMON: @x = common {{(dso_local )?}}global
// CHECK-NOCOMMON: @x = {{(dso_local )?}}global // CHECK-DEFAULT: @x = {{(dso_local )?}}global
int x; int x;
// CHECK-COMMON: @ABC = {{(dso_local )?}}global
// CHECK-DEFAULT: @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); typedef void* (*fn_t)(long a, long b, char *f, int c);
fn_t ABC __attribute__ ((nocommon)); fn_t ABC __attribute__ ((nocommon));
// CHECK-COMMON: @y = common {{(dso_local )?}}global
// CHECK-DEFAULT: @y = common {{(dso_local )?}}global // CHECK-DEFAULT: @y = common {{(dso_local )?}}global
// CHECK-NOCOMMON: @y = common {{(dso_local )?}}global
int y __attribute__((common)); int y __attribute__((common));

View File

@ -4,8 +4,8 @@
void (__attribute__((regparm(3), stdcall)) *pf) (); void (__attribute__((regparm(3), stdcall)) *pf) ();
void (__attribute__((regparm(2), stdcall)) foo)(int a) { void (__attribute__((regparm(2), stdcall)) foo)(int a) {
} }
// CHECK: @pf = common global void (...)* null // CHECK: @pf = global void (...)* null
// CHECK: define void @foo(i32 %a) // CHECK: define void @foo(i32 %a)
// CHECK-OK: @pf = common global void (...)* null // CHECK-OK: @pf = global void (...)* null
// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a) // CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)

View File

@ -64,5 +64,5 @@ struct S4
// CHECK: %struct.S4 = type { [3 x i8], %struct.T4, i32 } // CHECK: %struct.S4 = type { [3 x i8], %struct.T4, i32 }
// CHECK: %struct.T4 = type <{ i8, i32 }> // CHECK: %struct.T4 = type <{ i8, i32 }>
// CHECK: @refs = common global [[struct_ref]] // CHECK: @refs = global [[struct_ref]]
// CHECK: @ss = common global [[struct_S]] // CHECK: @ss = global [[struct_S]]

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm %s -o - -verify | FileCheck %s // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm %s -o - -verify | FileCheck %s
// CHECK: @weakvar = weak global // CHECK: @weakvar = weak global
// CHECK: @__weakvar_alias = common global // CHECK: @__weakvar_alias = global
// CHECK: @correct_linkage = weak global // CHECK: @correct_linkage = weak global

View File

@ -34,6 +34,6 @@ void foo() {
// CHECK: @M = hidden global // CHECK: @M = hidden global
// CHECK: @O = hidden global // CHECK: @O = hidden global
// CHECK: @I = external hidden // CHECK: @I = external hidden
// CHECK: @N = common hidden global // CHECK: @N = hidden global
// CHECK-NOT: @P // CHECK-NOT: @P

View File

@ -1,16 +1,16 @@
// RUN: %clang_cc1 -emit-llvm -w -o - %s | FileCheck %s // RUN: %clang_cc1 -emit-llvm -w -o - %s | FileCheck %s
// CHECK-DAG: @r = common {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer // CHECK-DAG: @r = {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
int r[]; int r[];
int (*a)[] = &r; int (*a)[] = &r;
struct s0; struct s0;
struct s0 x; struct s0 x;
// CHECK-DAG: @x = common {{(dso_local )?}}global %struct.s0 zeroinitializer // CHECK-DAG: @x = {{(dso_local )?}}global %struct.s0 zeroinitializer
struct s0 y; struct s0 y;
// CHECK-DAG: @y = common {{(dso_local )?}}global %struct.s0 zeroinitializer // CHECK-DAG: @y = {{(dso_local )?}}global %struct.s0 zeroinitializer
struct s0 *f0() { struct s0 *f0() {
return &y; return &y;
} }
@ -19,14 +19,14 @@ struct s0 {
int x; int x;
}; };
// CHECK-DAG: @b = common {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer // CHECK-DAG: @b = {{(dso_local )?}}global [1 x {{.*}}] zeroinitializer
int b[]; int b[];
int *f1() { int *f1() {
return b; return b;
} }
// Check that the most recent tentative definition wins. // Check that the most recent tentative definition wins.
// CHECK-DAG: @c = common {{(dso_local )?}}global [4 x {{.*}}] zeroinitializer // CHECK-DAG: @c = {{(dso_local )?}}global [4 x {{.*}}] zeroinitializer
int c[]; int c[];
int c[4]; int c[4];

View File

@ -21,24 +21,24 @@ int __thread __attribute__((tls_model("initial-exec"))) z;
// CHECK-GD: @z1 = global i32 0 // CHECK-GD: @z1 = global i32 0
// CHECK-GD: @f.y = internal thread_local global i32 0 // CHECK-GD: @f.y = internal thread_local global i32 0
// CHECK-GD: @z2 = common global i32 0 // CHECK-GD: @z2 = global i32 0
// CHECK-GD: @x = thread_local global i32 0 // CHECK-GD: @x = thread_local global i32 0
// CHECK-GD: @z = thread_local(initialexec) global i32 0 // CHECK-GD: @z = thread_local(initialexec) global i32 0
// CHECK-LD: @z1 = global i32 0 // CHECK-LD: @z1 = global i32 0
// CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0 // CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0
// CHECK-LD: @z2 = common global i32 0 // CHECK-LD: @z2 = global i32 0
// CHECK-LD: @x = thread_local(localdynamic) global i32 0 // CHECK-LD: @x = thread_local(localdynamic) global i32 0
// CHECK-LD: @z = thread_local(initialexec) global i32 0 // CHECK-LD: @z = thread_local(initialexec) global i32 0
// CHECK-IE: @z1 = global i32 0 // CHECK-IE: @z1 = global i32 0
// CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0 // CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0
// CHECK-IE: @z2 = common global i32 0 // CHECK-IE: @z2 = global i32 0
// CHECK-IE: @x = thread_local(initialexec) global i32 0 // CHECK-IE: @x = thread_local(initialexec) global i32 0
// CHECK-IE: @z = thread_local(initialexec) global i32 0 // CHECK-IE: @z = thread_local(initialexec) global i32 0
// CHECK-LE: @z1 = global i32 0 // CHECK-LE: @z1 = global i32 0
// CHECK-LE: @f.y = internal thread_local(localexec) global i32 0 // CHECK-LE: @f.y = internal thread_local(localexec) global i32 0
// CHECK-LE: @z2 = common global i32 0 // CHECK-LE: @z2 = global i32 0
// CHECK-LE: @x = thread_local(localexec) global i32 0 // CHECK-LE: @x = thread_local(localexec) global i32 0
// CHECK-LE: @z = thread_local(initialexec) global i32 0 // CHECK-LE: @z = thread_local(initialexec) global i32 0

View File

@ -3,15 +3,15 @@
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN // 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_def = global i32 0
// CHECK-DEFAULT: @g_com = common global i32 0 // CHECK-DEFAULT: @g_com = global i32 0
// CHECK-DEFAULT: @g_ext = external global i32 // CHECK-DEFAULT: @g_ext = external global i32
// CHECK-DEFAULT: @g_deferred = internal global // CHECK-DEFAULT: @g_deferred = internal global
// CHECK-PROTECTED: @g_def = protected global i32 0 // CHECK-PROTECTED: @g_def = protected global i32 0
// CHECK-PROTECTED: @g_com = common protected global i32 0 // CHECK-PROTECTED: @g_com = protected global i32 0
// CHECK-PROTECTED: @g_ext = external global i32 // CHECK-PROTECTED: @g_ext = external global i32
// CHECK-PROTECTED: @g_deferred = internal global // CHECK-PROTECTED: @g_deferred = internal global
// CHECK-HIDDEN: @g_def = hidden global i32 0 // CHECK-HIDDEN: @g_def = hidden global i32 0
// CHECK-HIDDEN: @g_com = common hidden global i32 0 // CHECK-HIDDEN: @g_com = hidden global i32 0
// CHECK-HIDDEN: @g_ext = external global i32 // CHECK-HIDDEN: @g_ext = external global i32
// CHECK-HIDDEN: @g_deferred = internal global // CHECK-HIDDEN: @g_deferred = internal global
int g_com; int g_com;

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
int c[1][3*2]; 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 // CHECK-LABEL: @f
int f(int * const m, int (**v)[*m * 2]) int f(int * const m, int (**v)[*m * 2])

View File

@ -1,10 +1,10 @@
// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -w -o - | FileCheck %s // RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -w -o - | FileCheck %s
// CHECK: @i = common {{(dso_local )?}}global [[INT:i[0-9]+]] 0 // CHECK: @i = {{(dso_local )?}}global [[INT:i[0-9]+]] 0
volatile int i, j, k; volatile int i, j, k;
volatile int ar[5]; volatile int ar[5];
volatile char c; volatile char c;
// CHECK: @ci = common {{(dso_local )?}}global [[CINT:.*]] zeroinitializer // CHECK: @ci = {{(dso_local )?}}global [[CINT:.*]] zeroinitializer
volatile _Complex int ci; volatile _Complex int ci;
volatile struct S { volatile struct S {
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,3 +0,0 @@
// RUN: %clang_cc1 -emit-llvm < %s | grep common
int i;

View File

@ -17,7 +17,7 @@ void call_imported_function() {
} }
// CHECK: @import_int = external dllimport global i32 // CHECK: @import_int = external dllimport global i32
// CHECK: @export_int = common dso_local dllexport global i32 0, align 4 // CHECK: @export_int = dso_local dllexport global i32 0, align 4
// CHECK: define dso_local dllexport arm_aapcs_vfpcc void @export_implemented_function() // CHECK: define dso_local dllexport arm_aapcs_vfpcc void @export_implemented_function()

View File

@ -30,7 +30,7 @@ const int cy; // .rodata.2
// CHECK: @x = global i32 0, align 4 #0 // CHECK: @x = global i32 0, align 4 #0
// CHECK: @y = global i32 0, align 4 #1 // CHECK: @y = global i32 0, align 4 #1
// CHECK: @z = common global i32 0, align 4 // CHECK: @z = global i32 0, align 4
// CHECK: @cx = constant i32 0, align 4 #2 // CHECK: @cx = constant i32 0, align 4 #2
// CHECK: @cy = constant i32 0, align 4 #3 // CHECK: @cy = constant i32 0, align 4 #3
// CHECK: @cz = constant i32 0, align 4 #1 // CHECK: @cz = constant i32 0, align 4 #1

View File

@ -30,6 +30,6 @@ int main () {
return 0; return 0;
} }
// CHECK-FRAGILE: @_FooClassReference = common global // CHECK-FRAGILE: @_FooClassReference = global
// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global // CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = global // CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = global

View File

@ -31,7 +31,7 @@ static inline void _inlineFunction() {
} }
@end @end
// CHECK: @__CFConstantStringClassReference = common global [24 x i32] zeroinitializer, align 16 // CHECK: @__CFConstantStringClassReference = 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: @_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() // CHECK-LABEL: define internal void @_inlineFunction()

View File

@ -53,10 +53,10 @@ void fc(constant int *arg) {}
#ifdef CL20 #ifdef CL20
int i; int i;
// CL20-DAG: @i = common {{(dso_local )?}}addrspace(1) global i32 0 // CL20-DAG: @i = {{(dso_local )?}}addrspace(1) global i32 0
int *ptr; int *ptr;
// CL20SPIR-DAG: @ptr = {{(common )?}}{{(dso_local )?}}addrspace(1) global i32 addrspace(4)* null // CL20SPIR-DAG: @ptr = {{(common )?}}{{(dso_local )?}}addrspace(1) global i32 addrspace(4)* null
// CL20AMDGCN-DAG: @ptr = common {{(dso_local )?}}addrspace(1) global i32* null // CL20AMDGCN-DAG: @ptr = {{(dso_local )?}}addrspace(1) global i32* null
#endif #endif
// SPIR: i32* %arg // SPIR: i32* %arg

View File

@ -1,11 +1,11 @@
// REQUIRES: amdgpu-registered-target // REQUIRES: amdgpu-registered-target
// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1 // CHECK: @One = local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1
unsigned char One[6442450944]; unsigned char One[6442450944];
// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4 // CHECK: @Two = local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4
global unsigned int Two[6442450944]; global unsigned int Two[6442450944];
kernel void large_globals(unsigned int id) { kernel void large_globals(unsigned int id) {
One[id] = id; One[id] = id;
Two[id + 1] = id + 1; Two[id + 1] = id + 1;

View File

@ -1,6 +1,7 @@
// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s // 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 -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---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 { typedef struct {
private char *p1; private char *p1;
@ -16,9 +17,6 @@ typedef struct {
generic char *p5; generic char *p5;
} StructTy2; } 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. // Test 0 as initializer.
// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4 // CHECK: @private_p = local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4
@ -183,34 +181,39 @@ void test_func_scope_var_local(void) {
// cannot have common linkage since common linkage requires zero initialization // cannot have common linkage since common linkage requires zero initialization
// and does not have explicit section. // and does not have explicit section.
// CHECK: @p1 = common local_unnamed_addr addrspace(1) global i8 addrspace(5)* null, align 4 // 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
private char *p1; private char *p1;
// CHECK: @p2 = weak local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8* null to i8 addrspace(3)*), align 4 // 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
local char *p2; local char *p2;
// CHECK: @p3 = common local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 8 // 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
constant char *p3; constant char *p3;
// CHECK: @p4 = common local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 8 // 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
global char *p4; global char *p4;
// CHECK: @p5 = common local_unnamed_addr addrspace(1) global i8* null, align 8 // 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
generic char *p5; generic char *p5;
// Test default initialization of structure. // Test default initialization of structure.
// 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 // 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
StructTy1 S1; StructTy1 S1;
// CHECK: @S2 = common local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 8 // CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 8
StructTy2 S2; StructTy2 S2;
// Test default initialization of array. // Test default initialization of array.
// 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 // 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
StructTy1 A1[2]; StructTy1 A1[2];
// CHECK: @A2 = common local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 8 // CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 8
StructTy2 A2[2]; StructTy2 A2[2];
// Test comparison with 0. // Test comparison with 0.

View File

@ -4,7 +4,7 @@
// CHECK-X86: "-disable-red-zone" // CHECK-X86: "-disable-red-zone"
// CHECK-X86: "-fno-builtin" // CHECK-X86: "-fno-builtin"
// CHECK-X86: "-fno-rtti" // CHECK-X86: "-fno-rtti"
// CHECK-X86: "-fno-common" // CHECK-X86-NOT: "-fcommon"
// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only -fbuiltin -fcommon %s 2>&1 | FileCheck --check-prefix=CHECK-X86-2 %s // 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-NOT: "-target-feature" "+strict-align"
// CHECK-ARM: "-fno-builtin" // CHECK-ARM: "-fno-builtin"
// CHECK-ARM: "-fno-rtti" // CHECK-ARM: "-fno-rtti"
// CHECK-ARM: "-fno-common" // CHECK-ARM-NOT: "-fcommon"
// RUN: %clang -target x86_64-apple-darwin10 \ // RUN: %clang -target x86_64-apple-darwin10 \
// RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \ // RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \

View File

@ -12,7 +12,7 @@
// CHECK-OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fno-gnu-keywords
// CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fno-builtin
// CHECK-OPTIONS2: -fshort-enums // CHECK-OPTIONS2: -fshort-enums
// CHECK-OPTIONS2: -fno-common // CHECK-OPTIONS2-NOT: -fcommon
// CHECK-OPTIONS2: -fno-show-source-location // CHECK-OPTIONS2: -fno-show-source-location
// RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s // RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s

View File

@ -22,7 +22,7 @@
// CHECK-AARCH64: "-fsanitize=shadow-call-stack" // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
// CHECK-X86_64: "-fsanitize=safe-stack" // CHECK-X86_64: "-fsanitize=safe-stack"
// CHECK: "-stack-protector" "2" // CHECK: "-stack-protector" "2"
// CHECK: "-fno-common" // CHECK-NOT: "-fcommon"
// CHECK: {{.*}}ld.lld{{.*}}" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" // CHECK: {{.*}}ld.lld{{.*}}" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments"
// CHECK: "--sysroot=[[SYSROOT]]" // CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie" // CHECK: "-pie"

View File

@ -0,0 +1,9 @@
// 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"

View File

@ -9,7 +9,7 @@
// CHECK: "-fno-use-cxa-atexit" // CHECK: "-fno-use-cxa-atexit"
// CHECK-NOT: "-fcxx-exceptions" // CHECK-NOT: "-fcxx-exceptions"
// CHECK-NOT: "-fexceptions" // CHECK-NOT: "-fexceptions"
// CHECK: "-fno-common" // CHECK-NOT: "-fcommon"
// CHECK: xcc" "-o" // CHECK: xcc" "-o"
// CHECK-NOT: "-fexceptions" // CHECK-NOT: "-fexceptions"
// CHECK: "-c" "-v" "-g" "-fverbose-asm" "A1Arg" "A2Arg" // CHECK: "-c" "-v" "-g" "-fverbose-asm" "A1Arg" "A2Arg"
@ -21,7 +21,7 @@
// CHECK-EXCEP: "-fno-use-cxa-atexit" // CHECK-EXCEP: "-fno-use-cxa-atexit"
// CHECK-EXCEP: "-fcxx-exceptions" // CHECK-EXCEP: "-fcxx-exceptions"
// CHECK-EXCEP: "-fexceptions" // CHECK-EXCEP: "-fexceptions"
// CHECK-EXCEP: "-fno-common" // CHECK-EXCEP-NOT: "-fcommon"
// CHECK-EXCEP: xcc" "-o" // CHECK-EXCEP: xcc" "-o"
// CHECK-EXCEP-NOT: "-fexceptions" // CHECK-EXCEP-NOT: "-fexceptions"
// CHECK-EXCEP: xcc" "-o" // CHECK-EXCEP: xcc" "-o"

View File

@ -5,7 +5,7 @@
// CHECK: module asm "foo" // CHECK: module asm "foo"
__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; int g0;
// CHECK: define dso_local i32 @f0() // CHECK: define dso_local i32 @f0()

View File

@ -7,7 +7,7 @@
// REQUIRES: x86-registered-target // REQUIRES: x86-registered-target
#include <xmmintrin.h> #include <xmmintrin.h>
// CHECK: @c = common global i8 0, align 16 // CHECK: @c = global i8 0, align 16
_MM_ALIGN16 char c; _MM_ALIGN16 char c;
// Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by

View File

@ -16,11 +16,11 @@
// Z-NOT: @z // Z-NOT: @z
// XA: @x = common global i32 0 // XA: @x = global i32 0
// XA-NOT: @x = common global i32 0 // XA-NOT: @x = global i32 0
// YA: @y = common global i32 0 // YA: @y = global i32 0
// YA-NOT: @y = common global i32 0 // YA-NOT: @y = global i32 0
// XB: @x2 = global i32 19 // XB: @x2 = global i32 19
// XB-NOT: @x2 = global i32 19 // XB-NOT: @x2 = global i32 19
@ -29,17 +29,17 @@ int x2 = 19;
// YB-NOT: @y2 = global i32 18 // YB-NOT: @y2 = global i32 18
int y2 = 18; int y2 = 18;
// AA: @incomplete_array = common global [1 x i32] // AA: @incomplete_array = global [1 x i32]
// AA-NOT: @incomplete_array = common global [1 x i32] // AA-NOT: @incomplete_array = global [1 x i32]
// AB: @incomplete_array2 = common global [17 x i32] // AB: @incomplete_array2 = global [17 x i32]
// AB-NOT: @incomplete_array2 = common global [17 x i32] // AB-NOT: @incomplete_array2 = global [17 x i32]
int incomplete_array2[17]; int incomplete_array2[17];
// AC: @incomplete_array3 = common global [1 x i32] // AC: @incomplete_array3 = global [1 x i32]
// AC-NOT: @incomplete_array3 = common global [1 x i32] // AC-NOT: @incomplete_array3 = global [1 x i32]
int incomplete_array3[]; int incomplete_array3[];
// S: @s = common global %struct.S // S: @s = global %struct.S
// S-NOT: @s = common global %struct.S // S-NOT: @s = global %struct.S
struct S { struct S {
int x, y; int x, y;
}; };

View File

@ -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 -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: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
// RUN: grep "@x = common global i32 0" %t | count 1 // RUN: grep "@x = global i32 0" %t | count 1
// RUN: not grep "@z" %t // RUN: not grep "@z" %t
// RUN: grep "@x2 = global i32 19" %t | count 1 // RUN: grep "@x2 = global i32 19" %t | count 1
int x2 = 19; int x2 = 19;
// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1 // RUN: grep "@incomplete_array = global .*1 x i32" %t | count 1
// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1 // RUN: grep "@incomplete_array2 = global .*17 x i32" %t | count 1
int incomplete_array2[17]; int incomplete_array2[17];
// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1 // RUN: grep "@incomplete_array3 = global .*1 x i32" %t | count 1
int incomplete_array3[]; int incomplete_array3[];
struct S { struct S {

View File

@ -1,6 +1,6 @@
// Test with pch. // Test with pch.
// 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 -fcommon -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 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
// REQUIRES: x86-registered-target // REQUIRES: x86-registered-target
// RUN: grep "@variable = common global i32 0" %t | count 1 // RUN: grep "@variable = common global i32 0" %t | count 1

View File

@ -6,14 +6,14 @@
#pragma GCC visibility push(hidden) #pragma GCC visibility push(hidden)
int v1; int v1;
// CHECK: @v1 = common hidden global i32 0, align 4 // CHECK: @v1 = hidden global i32 0, align 4
#pragma GCC visibility pop #pragma GCC visibility pop
int v2; int v2;
// CHECK: @v2 = common global i32 0, align 4 // CHECK: @v2 = global i32 0, align 4
_Pragma("GCC visibility push(hidden)"); _Pragma("GCC visibility push(hidden)");
int v3; int v3;
// CHECK: @v3 = common hidden global i32 0, align 4 // CHECK: @v3 = hidden global i32 0, align 4

View File

@ -1,9 +1,9 @@
// Test that we can properly report an ODR violation // Test that we can properly report an ODR violation
// between an instrumented global and a non-instrumented global. // between an instrumented global and a non-instrumented global.
// RUN: %clang_asan %s -fPIC -shared -o %dynamiclib1 -DFILE1 // RUN: %clang_asan -fcommon %s -fPIC -shared -o %dynamiclib1 -DFILE1
// RUN: %clang_asan %s -fPIC -shared -o %dynamiclib2 -DFILE2 // RUN: %clang_asan -fcommon %s -fPIC -shared -o %dynamiclib2 -DFILE2
// RUN: %clang_asan %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t // RUN: %clang_asan -fcommon %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t
// RUN: not %run %t 2>&1 | FileCheck %s // RUN: not %run %t 2>&1 | FileCheck %s
// //
// CHECK: The following global variable is not properly aligned. // CHECK: The following global variable is not properly aligned.

View File

@ -21,13 +21,13 @@ void __asan_set_shadow_f3(size_t addr, size_t size);
void __asan_set_shadow_f5(size_t addr, size_t size); void __asan_set_shadow_f5(size_t addr, size_t size);
void __asan_set_shadow_f8(size_t addr, size_t size); void __asan_set_shadow_f8(size_t addr, size_t size);
char a __attribute__((aligned(8))); char* a;
void f(long arg) { void f(long arg) {
size_t shadow_offset; size_t shadow_offset;
size_t shadow_scale; size_t shadow_scale;
__asan_get_shadow_mapping(&shadow_scale, &shadow_offset); __asan_get_shadow_mapping(&shadow_scale, &shadow_offset);
size_t addr = (((size_t)&a) >> shadow_scale) + shadow_offset; size_t addr = (((size_t)a) >> shadow_scale) + shadow_offset;
switch (arg) { switch (arg) {
// X00-NOT: AddressSanitizer // X00-NOT: AddressSanitizer
@ -61,9 +61,10 @@ void f(long arg) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
assert(argc > 1); assert(argc > 1);
a = malloc(8);
long arg = strtol(argv[1], 0, 16); long arg = strtol(argv[1], 0, 16);
f(arg); f(arg);
a = 1; *a = 1;
printf("PASS\n"); printf("PASS\n");
return 0; return 0;
} }