10c432b1aSTeresa Johnson; REQUIRES: x86-registered-target 20c432b1aSTeresa Johnson 30c432b1aSTeresa Johnson; Test to ensure that only referenced type ID records are emitted into 40c432b1aSTeresa Johnson; each distributed index file. 50c432b1aSTeresa Johnson 6290a8398STeresa Johnson; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %s 7290a8398STeresa Johnson; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2.o %p/Inputs/cfi-distributed.ll 80c432b1aSTeresa Johnson 90c432b1aSTeresa Johnson; RUN: llvm-lto2 run -thinlto-distributed-indexes %t1.o %t2.o \ 100c432b1aSTeresa Johnson; RUN: -o %t3 \ 110c432b1aSTeresa Johnson; RUN: -r=%t1.o,test,px \ 120c432b1aSTeresa Johnson; RUN: -r=%t1.o,_ZTV1B, \ 130c432b1aSTeresa Johnson; RUN: -r=%t1.o,_ZTV1B,px \ 140c432b1aSTeresa Johnson; RUN: -r=%t1.o,test2, \ 1584d912b7SVitaly Buka; RUN: -r=%t1.o,test3, \ 1684d912b7SVitaly Buka; RUN: -r=%t2.o,test1, \ 1784d912b7SVitaly Buka; RUN: -r=%t2.o,test3,p \ 180c432b1aSTeresa Johnson; RUN: -r=%t2.o,test2,px \ 190c432b1aSTeresa Johnson; RUN: -r=%t2.o,_ZTV1B2, \ 2084d912b7SVitaly Buka; RUN: -r=%t2.o,_ZTV1B2,px \ 2184d912b7SVitaly Buka; RUN: -r=%t2.o,_ZTV1B3, \ 2284d912b7SVitaly Buka; RUN: -r=%t2.o,_ZTV1B3,px 230c432b1aSTeresa Johnson 2484d912b7SVitaly Buka; Check that we have all needed type IDs. 250c432b1aSTeresa Johnson; RUN: llvm-dis %t1.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX1 2684d912b7SVitaly Buka 2784d912b7SVitaly Buka; Used by @llvm.type.test in @test 280c432b1aSTeresa Johnson; INDEX1: typeid: (name: "_ZTS1A" 2984d912b7SVitaly Buka 3084d912b7SVitaly Buka; Used by @llvm.type.test in @test2 imported to be called from @test 310c432b1aSTeresa Johnson; INDEX1: typeid: (name: "_ZTS1A2" 320c432b1aSTeresa Johnson 3384d912b7SVitaly Buka; Used by @llvm.type.test in @test1 imported to be called by alias 3484d912b7SVitaly Buka; @test3 from @test 3584d912b7SVitaly Buka; INDEX1: typeid: (name: "_ZTS1A3" 3684d912b7SVitaly Buka 3784d912b7SVitaly Buka; The second index file, should only contain the type IDs used in @test1 and @test2. 380c432b1aSTeresa Johnson; RUN: llvm-dis %t2.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX2 390c432b1aSTeresa Johnson; INDEX2-NOT: typeid: (name: "_ZTS1A" 400c432b1aSTeresa Johnson; INDEX2: typeid: (name: "_ZTS1A2" 4184d912b7SVitaly Buka; INDEX2: typeid: (name: "_ZTS1A3" 420c432b1aSTeresa Johnson 437b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 440c432b1aSTeresa Johnsontarget triple = "x86_64-grtev4-linux-gnu" 450c432b1aSTeresa Johnson 460c432b1aSTeresa Johnson%struct.B = type { %struct.A } 47*d5d3eb16SFangrui Song%struct.A = type { ptr } 480c432b1aSTeresa Johnson 49*d5d3eb16SFangrui Song@_ZTV1B = constant { [3 x ptr] } { [3 x ptr] [ptr undef, ptr undef, ptr undef] }, !type !0 500c432b1aSTeresa Johnson 51*d5d3eb16SFangrui Songdefine void @test(ptr %b) { 520c432b1aSTeresa Johnsonentry: 53*d5d3eb16SFangrui Song tail call void @test2(ptr %b) 54*d5d3eb16SFangrui Song tail call void @test3(ptr %b) 55*d5d3eb16SFangrui Song %vtable2 = load ptr, ptr %b 56*d5d3eb16SFangrui Song %0 = tail call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1A") 57*d5d3eb16SFangrui Song br i1 %0, label %cont, label %trap 580c432b1aSTeresa Johnson 590c432b1aSTeresa Johnsontrap: 600c432b1aSTeresa Johnson tail call void @llvm.trap() 610c432b1aSTeresa Johnson unreachable 620c432b1aSTeresa Johnson 630c432b1aSTeresa Johnsoncont: 640c432b1aSTeresa Johnson ret void 650c432b1aSTeresa Johnson} 660c432b1aSTeresa Johnson 67*d5d3eb16SFangrui Songdeclare void @test2(ptr) 68*d5d3eb16SFangrui Songdeclare void @test3(ptr) 69*d5d3eb16SFangrui Songdeclare i1 @llvm.type.test(ptr, metadata) 700c432b1aSTeresa Johnsondeclare void @llvm.trap() 710c432b1aSTeresa Johnson 720c432b1aSTeresa Johnson!0 = !{i64 16, !"_ZTS1A"} 730c432b1aSTeresa Johnson!1 = !{i64 16, !"_ZTS1B"} 74