brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 766591f Raw
64 lines · cpp
1// Test distributed ThinLTO backend handling of type tests2 3// REQUIRES: x86-registered-target4 5// Ensure that a distributed backend invocation of ThinLTO lowers the type test6// as expected.7// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm-bc -o %t.o %s8// RUN: llvm-dis %t.o -o - | FileCheck --check-prefix=TT %s9// RUN: llvm-lto -thinlto -o %t2 %t.o10// RUN: %clang -target x86_64-unknown-linux -O2 -o %t3.o -x ir %t.o -c -fthinlto-index=%t2.thinlto.bc -save-temps=obj11// RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s12// llvm-nm %t3.o | FileCheck --check-prefix=NM %s13 14// The pre-link bitcode produced by clang should contain a type test assume15// sequence.16// TT: [[TTREG:%[0-9]+]] = call i1 @llvm.public.type.test({{.*}}, metadata !"_ZTS1A")17// TT: void @llvm.assume(i1 [[TTREG]])18 19// The ThinLTO backend optimized bitcode should not have any type tests.20// OPT-NOT: @llvm.type.test21// OPT-NOT: @llvm.public.type.test22// We should have only one @llvm.assume call, the one that was expanded23// from the builtin in the IR below, not the one fed by the type test.24// OPT: %cmp = icmp ne ptr %{{.*}}, null25// OPT: void @llvm.assume(i1 %cmp)26// Check after the builtin assume again that we don't have any type tests27// OPT-NOT: @llvm.type.test28// OPT-NOT: @llvm.public.type.test29 30// NM: T _Z2afP1A31 32// Also check type test are lowered when the distributed ThinLTO backend clang33// invocation is passed an empty index file, in which case a non-ThinLTO34// compilation pipeline is invoked. If not lowered then LLVM CodeGen may assert.35// RUN: touch %t4.thinlto.bc36// O2 new PM37// RUN: %clang -target x86_64-unknown-linux -O2 -o %t4.o -x ir %t.o -c -fthinlto-index=%t4.thinlto.bc -save-temps=obj38// RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s39// llvm-nm %t4.o | FileCheck --check-prefix=NM %s40// O0 new PM41// RUN: %clang -target x86_64-unknown-linux -O0 -o %t4.o -x ir %t.o -c -fthinlto-index=%t4.thinlto.bc -save-temps=obj42// RUN: llvm-dis %t.s.4.opt.bc -o - | FileCheck --check-prefix=OPT %s43// llvm-nm %t4.o | FileCheck --check-prefix=NM %s44 45struct A {46  A();47  virtual void f();48};49 50struct B : virtual A {51  B();52};53 54A::A() {}55B::B() {}56 57void A::f() {58}59 60void af(A *a) {61  __builtin_assume(a != 0);62  a->f();63}64