[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / unique-internal-linkage-names.cpp
blobe847cea9d273c7e59ca51eeb2293099e6a15fcfb
1 // This test checks if internal linkage symbols get unique names with
2 // -funique-internal-linkage-names option.
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
4 // RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
6 static int glob;
7 static int foo() {
8 return 0;
11 int (*bar())() {
12 return foo;
15 int getGlob() {
16 return glob;
19 // Function local static variable and anonymous namespace namespace variable.
20 namespace {
21 int anon_m;
22 int getM() {
23 return anon_m;
25 } // namespace
27 int retAnonM() {
28 static int fGlob;
29 return getM() + fGlob;
32 // Multiversioning symbols
33 __attribute__((target("default"))) static int mver() {
34 return 0;
37 __attribute__((target("sse4.2"))) static int mver() {
38 return 1;
41 int mver_call() {
42 return mver();
45 namespace {
46 class A {
47 public:
48 A() {}
49 ~A() {}
53 void test() {
54 A a;
57 // PLAIN: @_ZL4glob = internal global
58 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
59 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
60 // PLAIN: define internal noundef i32 @_ZL3foov()
61 // PLAIN: define internal noundef i32 @_ZN12_GLOBAL__N_14getMEv
62 // PLAIN: define internal ptr @_ZL4mverv.resolver()
63 // PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
64 // PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
65 // PLAIN: define internal noundef i32 @_ZL4mverv()
66 // PLAIN: define internal noundef i32 @_ZL4mverv.sse4.2()
67 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
68 // UNIQUE: @_ZL4glob = internal global
69 // UNIQUE: @_ZZ8retAnonMvE5fGlob = internal global
70 // UNIQUE: @_ZN12_GLOBAL__N_16anon_mE = internal global
71 // UNIQUE: define internal noundef i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() #[[#ATTR:]] {
72 // UNIQUE: define internal noundef i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
73 // UNIQUE: define internal ptr @_ZL4mverv.[[MODHASH]].resolver()
74 // UNIQUE: define internal void @_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
75 // UNIQUE: define internal void @_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
76 // UNIQUE: define internal noundef i32 @_ZL4mverv.[[MODHASH]]()
77 // UNIQUE: define internal noundef i32 @_ZL4mverv.[[MODHASH]].sse4.2
78 // UNIQUE: attributes #[[#ATTR]] = { {{.*}}"sample-profile-suffix-elision-policy"{{.*}} }