1 ; Do setup work for all below tests: generate bitcode and combined index
2 ; RUN: llvm-as -function-summary %s -o %t.bc
3 ; RUN: llvm-as -function-summary %p/Inputs/funcimport.ll -o %t2.bc
4 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
7 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
9 ; Test import with smaller instruction limit
10 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
11 ; INSTLIM5-NOT: @staticfunc.llvm.2
13 define i32 @main() #0 {
15 call void (...) @weakalias()
16 call void (...) @analias()
17 %call = call i32 (...) @referencestatics()
18 %call1 = call i32 (...) @referenceglobals()
19 %call2 = call i32 (...) @referencecommon()
20 call void (...) @setfuncptr()
21 call void (...) @callfuncptr()
22 call void (...) @weakfunc()
26 ; Won't import weak alias
27 ; CHECK-DAG: declare extern_weak void @weakalias()
28 declare void @weakalias(...) #1
30 ; Aliases import the aliasee function
31 ; CHECK-DAG: @analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
32 ; CHECK-DAG: define available_externally void @globalfunc2()
33 declare void @analias(...) #1
35 ; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i)
36 ; INSTLIM5-DAG: declare i32 @referencestatics(...)
37 declare i32 @referencestatics(...) #1
39 ; The import of referencestatics will expose call to staticfunc that
40 ; should in turn be imported as a promoted/renamed and hidden function.
41 ; Ensure that the call is to the properly-renamed function.
42 ; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.2()
43 ; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.2()
45 ; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i)
46 declare i32 @referenceglobals(...) #1
48 ; The import of referenceglobals will expose call to globalfunc1 that
49 ; should in turn be imported.
50 ; CHECK-DAG: define available_externally void @globalfunc1()
52 ; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i)
53 declare i32 @referencecommon(...) #1
55 ; CHECK-DAG: define available_externally void @setfuncptr()
56 declare void @setfuncptr(...) #1
58 ; CHECK-DAG: define available_externally void @callfuncptr()
59 declare void @callfuncptr(...) #1
61 ; Ensure that all uses of local variable @P which has used in setfuncptr
62 ; and callfuncptr are to the same promoted/renamed global.
63 ; CHECK-DAG: @P.llvm.2 = available_externally hidden global void ()* null
64 ; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.2,
65 ; CHECK-DAG: store void ()* @staticfunc2.llvm.2, void ()** @P.llvm.2,
67 ; Won't import weak func
68 ; CHECK-DAG: declare void @weakfunc(...)
69 declare void @weakfunc(...) #1