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 -thinlto-split-lto-unit -o %t1.o %s 7; RUN: opt -thinlto-bc -thinlto-split-lto-unit -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=%t1.o,test3, \ 16; RUN: -r=%t2.o,test1, \ 17; RUN: -r=%t2.o,test3,p \ 18; RUN: -r=%t2.o,test2,px \ 19; RUN: -r=%t2.o,_ZTV1B2, \ 20; RUN: -r=%t2.o,_ZTV1B2,px \ 21; RUN: -r=%t2.o,_ZTV1B3, \ 22; RUN: -r=%t2.o,_ZTV1B3,px 23 24; Check that we have all needed type IDs. 25; RUN: llvm-dis %t1.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX1 26 27; Used by @llvm.type.test in @test 28; INDEX1: typeid: (name: "_ZTS1A" 29 30; Used by @llvm.type.test in @test2 imported to be called from @test 31; INDEX1: typeid: (name: "_ZTS1A2" 32 33; Used by @llvm.type.test in @test1 imported to be called by alias 34; @test3 from @test 35; INDEX1: typeid: (name: "_ZTS1A3" 36 37; The second index file, should only contain the type IDs used in @test1 and @test2. 38; RUN: llvm-dis %t2.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX2 39; INDEX2-NOT: typeid: (name: "_ZTS1A" 40; INDEX2: typeid: (name: "_ZTS1A2" 41; INDEX2: typeid: (name: "_ZTS1A3" 42 43target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 44target triple = "x86_64-grtev4-linux-gnu" 45 46%struct.B = type { %struct.A } 47%struct.A = type { ptr } 48 49@_ZTV1B = constant { [3 x ptr] } { [3 x ptr] [ptr undef, ptr undef, ptr undef] }, !type !0 50 51define void @test(ptr %b) { 52entry: 53 tail call void @test2(ptr %b) 54 tail call void @test3(ptr %b) 55 %vtable2 = load ptr, ptr %b 56 %0 = tail call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1A") 57 br i1 %0, label %cont, label %trap 58 59trap: 60 tail call void @llvm.trap() 61 unreachable 62 63cont: 64 ret void 65} 66 67declare void @test2(ptr) 68declare void @test3(ptr) 69declare i1 @llvm.type.test(ptr, metadata) 70declare void @llvm.trap() 71 72!0 = !{i64 16, !"_ZTS1A"} 73!1 = !{i64 16, !"_ZTS1B"} 74