xref: /llvm-project/llvm/test/ThinLTO/X86/lazyload_metadata.ll (revision d5d3eb16b7ab72529c83dacb2889811491e48909)
1; Do setup work for all below tests: generate bitcode and combined index
2; RUN: opt -module-summary %s -o %t.bc -bitcode-mdindex-threshold=0
3; RUN: opt -module-summary %p/Inputs/lazyload_metadata.ll -o %t2.bc -bitcode-mdindex-threshold=0
4; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
5; REQUIRES: asserts
6
7; Check that importing @globalfunc1 does not trigger loading all the global
8; metadata for @globalfunc2 and @globalfunc3
9
10; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc -stats 2> %t4.txt
11; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc -stats -disable-ondemand-mds-loading 2> %t5.txt
12; RUN: cat %t4.txt %t5.txt | FileCheck %s
13
14; Check llvm-lto call with lazy loading enabled
15; CHECK: [[#LAZY_RECORDS:]] bitcode-reader  - Number of Metadata records loaded
16; CHECK: 2 bitcode-reader  - Number of MDStrings loaded
17
18; Check llvm-lto call with lazy loading disabled
19; CHECK: [[#LAZY_RECORDS+9]] bitcode-reader  - Number of Metadata records loaded
20; CHECK: 7 bitcode-reader  - Number of MDStrings loaded
21
22target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-apple-macosx10.11.0"
24
25define void @globalfunc1(i32 %arg) {
26  %x = call i1 @llvm.type.test(ptr undef, metadata !"typeid1")
27  %tmp = add i32 %arg, 0, !metadata !2
28  ret void
29}
30
31; We need two functions here that will both reference the same metadata.
32; This is to force the metadata to be emitted in the global metadata block and
33; not in the function specific metadata.
34; These function are not imported and so we don't want to load their metadata.
35
36define void @globalfunc2(i32 %arg) {
37  %x = call i1 @llvm.type.test(ptr undef, metadata !"typeid1")
38  %tmp = add i32 %arg, 0, !metadata !1
39  ret void
40}
41
42define void @globalfunc3(i32 %arg) {
43  %tmp = add i32 %arg, 0, !metadata !1
44  ret void
45}
46
47declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
48
49!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
50!2 = !{!"Hello World"}
51!3 = !{!"3"}
52!4 = !{!"4"}
53!5 = !{!"5"}
54!6 = !{!9}
55!7 = !{!"7"}
56!8 = !{!"8"}
57!9 = !{!6}
58