]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ThinLTO/X86/cache-typeid-resolutions.ll
Vendor import of llvm trunk r300422:
[FreeBSD/FreeBSD.git] / test / ThinLTO / X86 / cache-typeid-resolutions.ll
1 ; RUN: opt -module-hash -module-summary %s -o %t.bc
2 ; RUN: opt -module-hash -module-summary %S/Inputs/cache-typeid-resolutions-import.ll -o %t-import.bc
3
4 ; RUN: llvm-as -o %t1.bc %S/Inputs/cache-typeid-resolutions1.ll
5 ; RUN: llvm-as -o %t2.bc %S/Inputs/cache-typeid-resolutions2.ll
6 ; RUN: llvm-as -o %t3.bc %S/Inputs/cache-typeid-resolutions3.ll
7
8 ; Two resolutions for typeid1: Unsat, Single
9 ; where both t and t-import are sensitive to typeid1's resolution
10 ; so 4 distinct objects in total.
11 ; RUN: rm -rf %t.cache
12 ; RUN: llvm-lto2 run -o %t.o %t.bc %t-import.bc -cache-dir %t.cache -r=%t.bc,f1,plx -r=%t.bc,f2,plx -r=%t-import.bc,importf1,plx -r=%t-import.bc,f1,lx -r=%t-import.bc,importf2,plx -r=%t-import.bc,f2,lx
13 ; RUN: llvm-lto2 run -o %t.o %t.bc %t-import.bc %t1.bc -cache-dir %t.cache -r=%t.bc,f1,plx -r=%t.bc,f2,plx -r=%t-import.bc,importf1,plx -r=%t-import.bc,f1,lx -r=%t-import.bc,importf2,plx -r=%t-import.bc,f2,lx -r=%t1.bc,vt1,plx
14 ; RUN: ls %t.cache | count 4
15
16 ; Three resolutions for typeid2: Indir, SingleImpl, UniqueRetVal
17 ; where both t and t-import are sensitive to typeid2's resolution
18 ; so 6 distinct objects in total.
19 ; RUN: rm -rf %t.cache
20 ; RUN: llvm-lto2 run -o %t.o %t.bc %t-import.bc -cache-dir %t.cache -r=%t.bc,f1,plx -r=%t.bc,f2,plx -r=%t-import.bc,importf1,plx -r=%t-import.bc,f1,lx -r=%t-import.bc,importf2,plx -r=%t-import.bc,f2,lx
21 ; RUN: llvm-lto2 run -o %t.o %t.bc %t-import.bc %t2.bc -cache-dir %t.cache -r=%t.bc,f1,plx -r=%t.bc,f2,plx -r=%t2.bc,vt2,plx -r=%t-import.bc,importf1,plx -r=%t-import.bc,f1,lx -r=%t-import.bc,importf2,plx -r=%t-import.bc,f2,lx
22 ; RUN: llvm-lto2 run -o %t.o %t.bc %t-import.bc %t3.bc -cache-dir %t.cache -r=%t.bc,f1,plx -r=%t.bc,f2,plx -r=%t3.bc,vt2a,plx -r=%t3.bc,vt2b,plx -r=%t-import.bc,importf1,plx -r=%t-import.bc,f1,lx -r=%t-import.bc,importf2,plx -r=%t-import.bc,f2,lx
23 ; RUN: ls %t.cache | count 6
24
25 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-unknown-linux-gnu"
27
28 define i1 @f1(i8* %p) {
29   %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
30   ret i1 %x
31 }
32
33 define i1 @f2(i8* %obj) {
34   %vtableptr = bitcast i8* %obj to [3 x i8*]**
35   %vtable = load [3 x i8*]*, [3 x i8*]** %vtableptr
36   %vtablei8 = bitcast [3 x i8*]* %vtable to i8*
37   %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2")
38   call void @llvm.assume(i1 %p)
39   %fptrptr = getelementptr [3 x i8*], [3 x i8*]* %vtable, i32 0, i32 0
40   %fptr = load i8*, i8** %fptrptr
41   %fptr_casted = bitcast i8* %fptr to i1 (i8*)*
42   %result = call i1 %fptr_casted(i8* %obj)
43   ret i1 %result
44 }
45
46 declare i1 @llvm.type.test(i8*, metadata)
47 declare void @llvm.assume(i1)