Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 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 | |
Teresa Johnson | 290a839 | 2019-01-11 18:31:57 +0000 | [diff] [blame] | 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 |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 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, \ |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 15 | ; RUN: -r=%t1.o,test3, \ |
| 16 | ; RUN: -r=%t2.o,test1, \ |
| 17 | ; RUN: -r=%t2.o,test3,p \ |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 18 | ; RUN: -r=%t2.o,test2,px \ |
| 19 | ; RUN: -r=%t2.o,_ZTV1B2, \ |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 20 | ; RUN: -r=%t2.o,_ZTV1B2,px \ |
| 21 | ; RUN: -r=%t2.o,_ZTV1B3, \ |
| 22 | ; RUN: -r=%t2.o,_ZTV1B3,px |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 23 | |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 24 | ; Check that we have all needed type IDs. |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 25 | ; RUN: llvm-dis %t1.o.thinlto.bc -o - | FileCheck %s --check-prefix=INDEX1 |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 26 | |
| 27 | ; Used by @llvm.type.test in @test |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 28 | ; INDEX1: typeid: (name: "_ZTS1A" |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 29 | |
| 30 | ; Used by @llvm.type.test in @test2 imported to be called from @test |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 31 | ; INDEX1: typeid: (name: "_ZTS1A2" |
| 32 | |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 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. |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 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" |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 41 | ; INDEX2: typeid: (name: "_ZTS1A3" |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 42 | |
| 43 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 44 | target triple = "x86_64-grtev4-linux-gnu" |
| 45 | |
| 46 | %struct.B = type { %struct.A } |
| 47 | %struct.A = type { i32 (...)** } |
| 48 | |
| 49 | @_ZTV1B = constant { [3 x i8*] } { [3 x i8*] [i8* undef, i8* undef, i8* undef] }, !type !0 |
| 50 | |
| 51 | define void @test(i8* %b) { |
| 52 | entry: |
| 53 | tail call void @test2(i8* %b) |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 54 | tail call void @test3(i8* %b) |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 55 | %0 = bitcast i8* %b to i8** |
| 56 | %vtable2 = load i8*, i8** %0 |
| 57 | %1 = tail call i1 @llvm.type.test(i8* %vtable2, metadata !"_ZTS1A") |
| 58 | br i1 %1, label %cont, label %trap |
| 59 | |
| 60 | trap: |
| 61 | tail call void @llvm.trap() |
| 62 | unreachable |
| 63 | |
| 64 | cont: |
| 65 | ret void |
| 66 | } |
| 67 | |
| 68 | declare void @test2(i8*) |
Vitaly Buka | 84d912b | 2018-09-19 18:51:42 +0000 | [diff] [blame] | 69 | declare void @test3(i8*) |
Teresa Johnson | 0c432b1 | 2018-07-19 22:25:56 +0000 | [diff] [blame] | 70 | declare i1 @llvm.type.test(i8*, metadata) |
| 71 | declare void @llvm.trap() |
| 72 | |
| 73 | !0 = !{i64 16, !"_ZTS1A"} |
| 74 | !1 = !{i64 16, !"_ZTS1B"} |