• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Do setup work for all below tests: generate bitcode and combined index
2; RUN: opt -module-summary %s -o %t.bc
3; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
4; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID
5
6; Do the import now
7; RUN: opt -disable-force-link-odr -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
8; "-stats" requires +Asserts.
9; REQUIRES: asserts
10
11; Test import with smaller instruction limit
12; RUN: opt -disable-force-link-odr -function-import -enable-import-metadata  -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
13; INSTLIM5-NOT: @staticfunc.llvm.
14
15; Test import with smaller instruction limit and without the -disable-force-link-odr
16; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=INSTLIM5ODR
17; INSTLIM5ODR: define linkonce_odr void @linkonceodr() {
18
19
20define i32 @main() #0 {
21entry:
22  call void (...) @weakalias()
23  call void (...) @analias()
24  call void (...) @linkoncealias()
25  %call = call i32 (...) @referencestatics()
26  %call1 = call i32 (...) @referenceglobals()
27  %call2 = call i32 (...) @referencecommon()
28  call void (...) @setfuncptr()
29  call void (...) @callfuncptr()
30  call void (...) @weakfunc()
31  call void (...) @linkoncefunc2()
32  call void (...) @referencelargelinkonce()
33  ret i32 0
34}
35
36; Won't import weak alias
37; CHECK-DAG: declare void @weakalias
38declare void @weakalias(...) #1
39
40; Cannot create an alias to available_externally
41; CHECK-DAG: declare void @analias
42declare void @analias(...) #1
43
44; FIXME: Add this checking back when follow on fix to add alias summary
45; records is committed.
46; Aliases import the aliasee function
47declare void @linkoncealias(...) #1
48
49; INSTLIMDEF-DAG: Import referencestatics
50; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i) !thinlto_src_module !0 {
51; INSTLIM5-DAG: declare i32 @referencestatics(...)
52declare i32 @referencestatics(...) #1
53
54; The import of referencestatics will expose call to staticfunc that
55; should in turn be imported as a promoted/renamed and hidden function.
56; Ensure that the call is to the properly-renamed function.
57; INSTLIMDEF-DAG: Import staticfunc
58; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.
59; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.{{.*}} !thinlto_src_module !0 {
60
61; INSTLIMDEF-DAG: Import referenceglobals
62; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i) !thinlto_src_module !0 {
63declare i32 @referenceglobals(...) #1
64
65; The import of referenceglobals will expose call to globalfunc1 that
66; should in turn be imported.
67; INSTLIMDEF-DAG: Import globalfunc1
68; CHECK-DAG: define available_externally void @globalfunc1() !thinlto_src_module !0
69
70; INSTLIMDEF-DAG: Import referencecommon
71; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i) !thinlto_src_module !0 {
72declare i32 @referencecommon(...) #1
73
74; INSTLIMDEF-DAG: Import setfuncptr
75; CHECK-DAG: define available_externally void @setfuncptr() !thinlto_src_module !0 {
76declare void @setfuncptr(...) #1
77
78; INSTLIMDEF-DAG: Import callfuncptr
79; CHECK-DAG: define available_externally void @callfuncptr() !thinlto_src_module !0 {
80declare void @callfuncptr(...) #1
81
82; Ensure that all uses of local variable @P which has used in setfuncptr
83; and callfuncptr are to the same promoted/renamed global.
84; CHECK-DAG: @P.llvm.{{.*}} = external hidden global void ()*
85; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.
86; CHECK-DAG: store void ()* @staticfunc2.llvm.{{.*}}, void ()** @P.llvm.
87
88; Ensure that @referencelargelinkonce definition is pulled in, but later we
89; also check that the linkonceodr function is not.
90; CHECK-DAG: define available_externally void @referencelargelinkonce() !thinlto_src_module !0 {
91; INSTLIM5-DAG: declare void @linkonceodr()
92declare void @referencelargelinkonce(...)
93
94; Won't import weak func
95; CHECK-DAG: declare void @weakfunc(...)
96declare void @weakfunc(...) #1
97
98; Won't import linkonce func
99; CHECK-DAG: declare void @linkoncefunc2(...)
100declare void @linkoncefunc2(...) #1
101
102; INSTLIMDEF-DAG: Import funcwithpersonality
103; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !thinlto_src_module !0 {
104; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()
105
106; INSTLIMDEF-DAG: Import globalfunc2
107; INSTLIMDEF-DAG: 13 function-import - Number of functions imported
108; CHECK-DAG: !0 = !{!"{{.*}}/Inputs/funcimport.ll"}
109
110; The actual GUID values will depend on path to test.
111; GUID-DAG: GUID {{.*}} is weakalias
112; GUID-DAG: GUID {{.*}} is referenceglobals
113; GUID-DAG: GUID {{.*}} is weakfunc
114; GUID-DAG: GUID {{.*}} is main
115; GUID-DAG: GUID {{.*}} is referencecommon
116; GUID-DAG: GUID {{.*}} is analias
117; GUID-DAG: GUID {{.*}} is referencestatics
118; GUID-DAG: GUID {{.*}} is linkoncealias
119; GUID-DAG: GUID {{.*}} is setfuncptr
120; GUID-DAG: GUID {{.*}} is callfuncptr
121; GUID-DAG: GUID {{.*}} is funcwithpersonality
122; GUID-DAG: GUID {{.*}} is setfuncptr
123; GUID-DAG: GUID {{.*}} is staticfunc2
124; GUID-DAG: GUID {{.*}} is __gxx_personality_v0
125; GUID-DAG: GUID {{.*}} is referencestatics
126; GUID-DAG: GUID {{.*}} is globalfunc1
127; GUID-DAG: GUID {{.*}} is globalfunc2
128; GUID-DAG: GUID {{.*}} is P
129; GUID-DAG: GUID {{.*}} is staticvar
130; GUID-DAG: GUID {{.*}} is commonvar
131; GUID-DAG: GUID {{.*}} is weakalias
132; GUID-DAG: GUID {{.*}} is staticfunc
133; GUID-DAG: GUID {{.*}} is weakfunc
134; GUID-DAG: GUID {{.*}} is referenceglobals
135; GUID-DAG: GUID {{.*}} is weakvar
136; GUID-DAG: GUID {{.*}} is staticconstvar
137; GUID-DAG: GUID {{.*}} is analias
138; GUID-DAG: GUID {{.*}} is globalvar
139; GUID-DAG: GUID {{.*}} is referencecommon
140; GUID-DAG: GUID {{.*}} is linkoncealias
141; GUID-DAG: GUID {{.*}} is callfuncptr
142; GUID-DAG: GUID {{.*}} is linkoncefunc
143