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
7 ; Check that importing @globalfunc1 does not trigger loading all the global
8 ; metadata for @globalfunc2 and @globalfunc3
10 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
11 ; RUN: -o /dev/null -stats \
12 ; RUN: 2>&1 | FileCheck %s -check-prefix=LAZY
13 ; LAZY: 65 bitcode-reader - Number of Metadata records loaded
14 ; LAZY: 2 bitcode-reader - Number of MDStrings loaded
16 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
17 ; RUN: -o /dev/null -disable-ondemand-mds-loading -stats \
18 ; RUN: 2>&1 | FileCheck %s -check-prefix=NOTLAZY
19 ; NOTLAZY: 74 bitcode-reader - Number of Metadata records loaded
20 ; NOTLAZY: 7 bitcode-reader - Number of MDStrings loaded
23 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
24 target triple = "x86_64-apple-macosx10.11.0"
26 define void @globalfunc1(i32 %arg) {
27 %x = call i1 @llvm.type.test(i8* undef, metadata !"typeid1")
28 %tmp = add i32 %arg, 0, !metadata !2
32 ; We need two functions here that will both reference the same metadata.
33 ; This is to force the metadata to be emitted in the global metadata block and
34 ; not in the function specific metadata.
35 ; These function are not imported and so we don't want to load their metadata.
37 define void @globalfunc2(i32 %arg) {
38 %x = call i1 @llvm.type.test(i8* undef, metadata !"typeid1")
39 %tmp = add i32 %arg, 0, !metadata !1
43 define void @globalfunc3(i32 %arg) {
44 %tmp = add i32 %arg, 0, !metadata !1
48 declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
50 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
51 !2 = !{!"Hello World"}