1 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm -fvirtual-function-elimination -fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-VFE
2 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm -fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOVFE
3 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc -emit-llvm -fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK-MS --check-prefix=CHECK-NOVFE
5 // Check that in ThinLTO we also get vcall_visibility summary entries in the bitcode
6 // RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -emit-llvm-bc -fwhole-program-vtables -o - %s | llvm-dis -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOVFE --check-prefix=CHECK-SUMMARY
9 // Anonymous namespace.
11 // CHECK: @_ZTVN12_GLOBAL__N_11AE = {{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
12 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4A@?A{{.*}}@@6B@"{{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
15 virtual int f() { return 1; }
24 // CHECK: @_ZTV1B = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]
25 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4B@@6B@"{{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]
26 struct __attribute__((visibility("hidden"))) B
{
28 virtual int f() { return 1; }
35 // Default visibility.
36 // CHECK-NOT: @_ZTV1C = {{.*}} !vcall_visibility
37 // On MS default is hidden
38 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4C@@6B@"{{.*}} !vcall_visibility [[VIS_DSO]]
39 struct __attribute__((visibility("default"))) C
{
41 virtual int f() { return 1; }
48 // Hidden visibility, public LTO visibility.
49 // CHECK-NOT: @_ZTV1D = {{.*}} !vcall_visibility
50 // CHECK-MS-NOT: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4D@@6B@"{{.*}} !vcall_visibility
51 struct __attribute__((visibility("hidden"))) [[clang::lto_visibility_public
]] D
{
53 virtual int f() { return 1; }
60 // Hidden visibility, but inherits from class with default visibility.
61 // CHECK-NOT: @_ZTV1E = {{.*}} !vcall_visibility
62 // On MS default is hidden
63 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4E@@6B@"{{.*}} !vcall_visibility [[VIS_DSO]]
64 struct __attribute__((visibility("hidden"))) E
: C
{
66 virtual int f() { return 1; }
73 // Anonymous namespace, but inherits from class with default visibility.
74 // CHECK-NOT: @_ZTVN12_GLOBAL__N_11FE = {{.*}} !vcall_visibility
75 // On MS default is hidden
76 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4F@?A{{.*}}@@6B@"{{.*}} !vcall_visibility [[VIS_DSO]]
78 struct __attribute__((visibility("hidden"))) F
: C
{
80 virtual int f() { return 1; }
88 // Anonymous namespace, but inherits from class with hidden visibility.
89 // CHECK: @_ZTVN12_GLOBAL__N_11GE = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]
90 // CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}@"??_R4G@?A{{.*}}@@6B@"{{.*}} !vcall_visibility [[VIS_DSO]]
92 struct __attribute__((visibility("hidden"))) G
: B
{
94 virtual int f() { return 1; }
101 // CHECK-MS-DAG: [[VIS_DSO]] = !{i64 1}
102 // CHECK-MS-DAG: [[VIS_TU]] = !{i64 2}
103 // CHECK-DAG: [[VIS_DSO]] = !{i64 1}
104 // CHECK-DAG: [[VIS_TU]] = !{i64 2}
105 // CHECK-VFE-DAG: !{i32 1, !"Virtual Function Elim", i32 1}
106 // CHECK-NOVFE-DAG: !{i32 1, !"Virtual Function Elim", i32 0}
108 // CHECK-SUMMARY-DAG: gv: (name: "_ZTV1B", {{.*}} vcall_visibility: 1
109 // CHECK-SUMMARY-DAG: gv: (name: "_ZTVN12_GLOBAL__N_11FE", {{.*}} vcall_visibility: 0
110 // CHECK-SUMMARY-DAG: gv: (name: "_ZTV1D", {{.*}} vcall_visibility: 0
111 // CHECK-SUMMARY-DAG: gv: (name: "_ZTV1C", {{.*}} vcall_visibility: 0
112 // CHECK-SUMMARY-DAG: gv: (name: "_ZTV1E", {{.*}} vcall_visibility: 0
113 // CHECK-SUMMARY-DAG: gv: (name: "_ZTVN12_GLOBAL__N_11AE", {{.*}} vcall_visibility: 2
114 // CHECK-SUMMARY-DAG: gv: (name: "_ZTVN12_GLOBAL__N_11GE", {{.*}} vcall_visibility: 1