[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / thinlto-distributed-type-metadata.cpp
blob766591f510937675f67855b3b7819236853658e2
1 // Test distributed ThinLTO backend handling of type tests
3 // REQUIRES: x86-registered-target
5 // Ensure that a distributed backend invocation of ThinLTO lowers the type test
6 // as expected.
7 // RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm-bc -o %t.o %s
8 // RUN: llvm-dis %t.o -o - | FileCheck --check-prefix=TT %s
9 // RUN: llvm-lto -thinlto -o %t2 %t.o
10 // RUN: %clang -target x86_64-unknown-linux -O2 -o %t3.o -x ir %t.o -c -fthinlto-index=%t2.thinlto.bc -save-temps=obj
11 // RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
12 // llvm-nm %t3.o | FileCheck --check-prefix=NM %s
14 // The pre-link bitcode produced by clang should contain a type test assume
15 // sequence.
16 // TT: [[TTREG:%[0-9]+]] = call i1 @llvm.public.type.test({{.*}}, metadata !"_ZTS1A")
17 // TT: void @llvm.assume(i1 [[TTREG]])
19 // The ThinLTO backend optimized bitcode should not have any type tests.
20 // OPT-NOT: @llvm.type.test
21 // OPT-NOT: @llvm.public.type.test
22 // We should have only one @llvm.assume call, the one that was expanded
23 // from the builtin in the IR below, not the one fed by the type test.
24 // OPT: %cmp = icmp ne ptr %{{.*}}, null
25 // OPT: void @llvm.assume(i1 %cmp)
26 // Check after the builtin assume again that we don't have any type tests
27 // OPT-NOT: @llvm.type.test
28 // OPT-NOT: @llvm.public.type.test
30 // NM: T _Z2afP1A
32 // Also check type test are lowered when the distributed ThinLTO backend clang
33 // invocation is passed an empty index file, in which case a non-ThinLTO
34 // compilation pipeline is invoked. If not lowered then LLVM CodeGen may assert.
35 // RUN: touch %t4.thinlto.bc
36 // O2 new PM
37 // RUN: %clang -target x86_64-unknown-linux -O2 -o %t4.o -x ir %t.o -c -fthinlto-index=%t4.thinlto.bc -save-temps=obj
38 // RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
39 // llvm-nm %t4.o | FileCheck --check-prefix=NM %s
40 // O0 new PM
41 // RUN: %clang -target x86_64-unknown-linux -O0 -o %t4.o -x ir %t.o -c -fthinlto-index=%t4.thinlto.bc -save-temps=obj
42 // RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
43 // llvm-nm %t4.o | FileCheck --check-prefix=NM %s
45 struct A {
46 A();
47 virtual void f();
50 struct B : virtual A {
51 B();
54 A::A() {}
55 B::B() {}
57 void A::f() {
60 void af(A *a) {
61 __builtin_assume(a != 0);
62 a->f();