unique-internal-linkage-names.cpp
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// This test checks if internal linkage symbols get unique names with
// -funique-internal-linkage-names option.
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
static int glob;
static int foo() {
return 0;
}
int (*bar())() {
return foo;
}
int getGlob() {
return glob;
}
// Function local static variable and anonymous namespace namespace variable.
namespace {
int anon_m;
int getM() {
return anon_m;
}
} // namespace
int retAnonM() {
static int fGlob;
return getM() + fGlob;
}
// Multiversioning symbols
__attribute__((target("default"))) static int mver() {
return 0;
}
__attribute__((target("sse4.2"))) static int mver() {
return 1;
}
int mver_call() {
return mver();
}
// PLAIN: @_ZL4glob = internal global
// PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
// PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
// PLAIN: define internal i32 @_ZL3foov()
// PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
// PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
// PLAIN: define internal i32 @_ZL4mverv()
// PLAIN: define internal i32 @_ZL4mverv.sse4.2()
// UNIQUE: @_ZL4glob.{{[0-9a-f]+}} = internal global
// UNIQUE: @_ZZ8retAnonMvE5fGlob.{{[0-9a-f]+}} = internal global
// UNIQUE: @_ZN12_GLOBAL__N_16anon_mE.{{[0-9a-f]+}} = internal global
// UNIQUE: define internal i32 @_ZL3foov.{{[0-9a-f]+}}()
// UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.{{[0-9a-f]+}}
// UNIQUE: define weak_odr i32 ()* @_ZL4mverv.resolver()
// UNIQUE: define internal i32 @_ZL4mverv.{{[0-9a-f]+}}()
// UNIQUE: define internal i32 @_ZL4mverv.sse4.2.{{[0-9a-f]+}}