Home | History | Annotate | Download | only in X86
      1 ; REQUIRES: x86-registered-target
      2 
      3 ; Test to ensure that only referenced type ID records are emitted into
      4 ; each distributed index file.
      5 
      6 ; RUN: opt -thinlto-bc -o %t1.o %s
      7 ; RUN: opt -thinlto-bc -o %t2.o %p/Inputs/cfi-distributed.ll
      8 
      9 ; RUN: llvm-lto2 run -thinlto-distributed-indexes %t1.o %t2.o \
     10 ; RUN:   -o %t3 \
     11 ; RUN:   -r=%t1.o,test,px \
     12 ; RUN:   -r=%t1.o,_ZTV1B, \
     13 ; RUN:   -r=%t1.o,_ZTV1B,px \
     14 ; RUN:   -r=%t1.o,test2, \
     15 ; RUN:   -r=%t2.o,test2,px \
     16 ; RUN:   -r=%t2.o,_ZTV1B2, \
     17 ; RUN:   -r=%t2.o,_ZTV1B2,px
     18 
     19 ; Since @test calls @test2, the latter should be imported here and the
     20 ; first index file should reference both type ids.
     21 ; RUN: llvm-dis %t1.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX1
     22 ; INDEX1: typeid: (name: "_ZTS1A"
     23 ; INDEX1: typeid: (name: "_ZTS1A2"
     24 
     25 ; The second index file, corresponding to @test2, should only contain the
     26 ; typeid for _ZTS1A.
     27 ; RUN: llvm-dis %t2.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX2
     28 ; INDEX2-NOT: typeid: (name: "_ZTS1A"
     29 ; INDEX2: typeid: (name: "_ZTS1A2"
     30 
     31 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
     32 target triple = "x86_64-grtev4-linux-gnu"
     33 
     34 %struct.B = type { %struct.A }
     35 %struct.A = type { i32 (...)** }
     36 
     37 @_ZTV1B = constant { [3 x i8*] } { [3 x i8*] [i8* undef, i8* undef, i8* undef] }, !type !0
     38 
     39 define void @test(i8* %b) {
     40 entry:
     41   tail call void @test2(i8* %b)
     42   %0 = bitcast i8* %b to i8**
     43   %vtable2 = load i8*, i8** %0
     44   %1 = tail call i1 @llvm.type.test(i8* %vtable2, metadata !"_ZTS1A")
     45   br i1 %1, label %cont, label %trap
     46 
     47 trap:
     48   tail call void @llvm.trap()
     49   unreachable
     50 
     51 cont:
     52   ret void
     53 }
     54 
     55 declare void @test2(i8*)
     56 declare i1 @llvm.type.test(i8*, metadata)
     57 declare void @llvm.trap()
     58 
     59 !0 = !{i64 16, !"_ZTS1A"}
     60 !1 = !{i64 16, !"_ZTS1B"}
     61