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
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
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
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
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
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
50 struct B
: virtual A
{
61 __builtin_assume(a
!= 0);