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