2015-11-24 14:07:49 +08:00
|
|
|
; Do setup work for all below tests: generate bitcode and combined index
|
2016-04-13 05:35:18 +08:00
|
|
|
; RUN: opt -module-summary %s -o %t.bc
|
|
|
|
; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
|
2016-04-05 02:52:58 +08:00
|
|
|
; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID
|
2015-11-24 14:07:49 +08:00
|
|
|
|
|
|
|
; Do the import now
|
2016-07-09 07:01:49 +08:00
|
|
|
; 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
|
2016-07-19 05:22:24 +08:00
|
|
|
; Try again with new pass manager
|
|
|
|
; RUN: opt -disable-force-link-odr -passes='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
|
2016-03-28 10:14:49 +08:00
|
|
|
; "-stats" requires +Asserts.
|
2016-07-09 06:55:48 +08:00
|
|
|
; REQUIRES: asserts
|
2015-11-25 06:55:46 +08:00
|
|
|
|
|
|
|
; Test import with smaller instruction limit
|
2016-07-09 07:01:49 +08:00
|
|
|
; 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
|
2016-04-12 07:26:46 +08:00
|
|
|
; INSTLIM5-NOT: @staticfunc.llvm.
|
2015-11-24 14:07:49 +08:00
|
|
|
|
2016-04-21 09:59:39 +08:00
|
|
|
; Test import with smaller instruction limit and without the -disable-force-link-odr
|
|
|
|
; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=INSTLIM5ODR
|
2016-07-07 04:26:25 +08:00
|
|
|
; INSTLIM5ODR: define linkonce_odr void @linkonceodr() {
|
2016-04-21 09:59:39 +08:00
|
|
|
|
|
|
|
|
2015-11-24 14:07:49 +08:00
|
|
|
define i32 @main() #0 {
|
|
|
|
entry:
|
|
|
|
call void (...) @weakalias()
|
|
|
|
call void (...) @analias()
|
2015-11-27 03:22:59 +08:00
|
|
|
call void (...) @linkoncealias()
|
2015-11-24 14:07:49 +08:00
|
|
|
%call = call i32 (...) @referencestatics()
|
|
|
|
%call1 = call i32 (...) @referenceglobals()
|
|
|
|
%call2 = call i32 (...) @referencecommon()
|
|
|
|
call void (...) @setfuncptr()
|
|
|
|
call void (...) @callfuncptr()
|
2015-11-25 00:10:43 +08:00
|
|
|
call void (...) @weakfunc()
|
2016-05-03 08:27:28 +08:00
|
|
|
call void (...) @linkoncefunc2()
|
2016-04-21 09:59:39 +08:00
|
|
|
call void (...) @referencelargelinkonce()
|
2015-11-24 14:07:49 +08:00
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
2015-11-25 00:10:43 +08:00
|
|
|
; Won't import weak alias
|
2015-12-03 06:22:24 +08:00
|
|
|
; CHECK-DAG: declare void @weakalias
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @weakalias(...) #1
|
2015-11-25 00:10:43 +08:00
|
|
|
|
2015-11-27 03:22:59 +08:00
|
|
|
; Cannot create an alias to available_externally
|
2015-12-03 06:22:24 +08:00
|
|
|
; CHECK-DAG: declare void @analias
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @analias(...) #1
|
|
|
|
|
2016-04-11 21:58:45 +08:00
|
|
|
; FIXME: Add this checking back when follow on fix to add alias summary
|
|
|
|
; records is committed.
|
2015-11-27 03:22:59 +08:00
|
|
|
; Aliases import the aliasee function
|
|
|
|
declare void @linkoncealias(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referencestatics
|
2016-07-07 04:26:25 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i) !thinlto_src_module !0 {
|
2015-11-25 06:55:46 +08:00
|
|
|
; INSTLIM5-DAG: declare i32 @referencestatics(...)
|
2015-11-24 14:07:49 +08:00
|
|
|
declare i32 @referencestatics(...) #1
|
|
|
|
|
2015-11-25 03:55:04 +08:00
|
|
|
; The import of referencestatics will expose call to staticfunc that
|
|
|
|
; should in turn be imported as a promoted/renamed and hidden function.
|
|
|
|
; Ensure that the call is to the properly-renamed function.
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import staticfunc
|
2016-04-12 07:26:46 +08:00
|
|
|
; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.
|
2016-07-07 04:26:25 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.{{.*}} !thinlto_src_module !0 {
|
2015-11-25 03:55:04 +08:00
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referenceglobals
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i) !thinlto_src_module !0 {
|
2015-11-24 14:07:49 +08:00
|
|
|
declare i32 @referenceglobals(...) #1
|
|
|
|
|
2015-11-25 03:55:04 +08:00
|
|
|
; The import of referenceglobals will expose call to globalfunc1 that
|
|
|
|
; should in turn be imported.
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import globalfunc1
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally void @globalfunc1() !thinlto_src_module !0
|
2015-11-25 03:55:04 +08:00
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referencecommon
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i) !thinlto_src_module !0 {
|
2015-11-24 14:07:49 +08:00
|
|
|
declare i32 @referencecommon(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import setfuncptr
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally void @setfuncptr() !thinlto_src_module !0 {
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @setfuncptr(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import callfuncptr
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally void @callfuncptr() !thinlto_src_module !0 {
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @callfuncptr(...) #1
|
|
|
|
|
2015-11-25 03:46:58 +08:00
|
|
|
; Ensure that all uses of local variable @P which has used in setfuncptr
|
|
|
|
; and callfuncptr are to the same promoted/renamed global.
|
2016-04-12 07:26:46 +08:00
|
|
|
; CHECK-DAG: @P.llvm.{{.*}} = external hidden global void ()*
|
|
|
|
; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.
|
|
|
|
; CHECK-DAG: store void ()* @staticfunc2.llvm.{{.*}}, void ()** @P.llvm.
|
2015-11-25 03:46:58 +08:00
|
|
|
|
2016-04-21 09:59:39 +08:00
|
|
|
; Ensure that @referencelargelinkonce definition is pulled in, but later we
|
|
|
|
; also check that the linkonceodr function is not.
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: define available_externally void @referencelargelinkonce() !thinlto_src_module !0 {
|
2016-04-21 09:59:39 +08:00
|
|
|
; INSTLIM5-DAG: declare void @linkonceodr()
|
|
|
|
declare void @referencelargelinkonce(...)
|
|
|
|
|
2015-11-24 14:07:49 +08:00
|
|
|
; Won't import weak func
|
2015-11-25 00:10:43 +08:00
|
|
|
; CHECK-DAG: declare void @weakfunc(...)
|
|
|
|
declare void @weakfunc(...) #1
|
|
|
|
|
2016-05-03 08:27:28 +08:00
|
|
|
; Won't import linkonce func
|
|
|
|
; CHECK-DAG: declare void @linkoncefunc2(...)
|
|
|
|
declare void @linkoncefunc2(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import funcwithpersonality
|
2016-07-07 04:26:25 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !thinlto_src_module !0 {
|
2016-04-12 07:26:46 +08:00
|
|
|
; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()
|
2016-03-27 23:27:30 +08:00
|
|
|
|
|
|
|
; INSTLIMDEF-DAG: Import globalfunc2
|
2016-04-21 09:59:39 +08:00
|
|
|
; INSTLIMDEF-DAG: 13 function-import - Number of functions imported
|
2016-07-07 04:26:25 +08:00
|
|
|
; CHECK-DAG: !0 = !{!"{{.*}}/Inputs/funcimport.ll"}
|
2016-04-05 02:52:58 +08:00
|
|
|
|
2016-04-05 03:11:00 +08:00
|
|
|
; The actual GUID values will depend on path to test.
|
|
|
|
; GUID-DAG: GUID {{.*}} is weakalias
|
|
|
|
; GUID-DAG: GUID {{.*}} is referenceglobals
|
|
|
|
; GUID-DAG: GUID {{.*}} is weakfunc
|
|
|
|
; GUID-DAG: GUID {{.*}} is main
|
|
|
|
; GUID-DAG: GUID {{.*}} is referencecommon
|
|
|
|
; GUID-DAG: GUID {{.*}} is analias
|
|
|
|
; GUID-DAG: GUID {{.*}} is referencestatics
|
|
|
|
; GUID-DAG: GUID {{.*}} is linkoncealias
|
|
|
|
; GUID-DAG: GUID {{.*}} is setfuncptr
|
|
|
|
; GUID-DAG: GUID {{.*}} is callfuncptr
|
|
|
|
; GUID-DAG: GUID {{.*}} is funcwithpersonality
|
|
|
|
; GUID-DAG: GUID {{.*}} is setfuncptr
|
|
|
|
; GUID-DAG: GUID {{.*}} is staticfunc2
|
|
|
|
; GUID-DAG: GUID {{.*}} is __gxx_personality_v0
|
|
|
|
; GUID-DAG: GUID {{.*}} is referencestatics
|
|
|
|
; GUID-DAG: GUID {{.*}} is globalfunc1
|
|
|
|
; GUID-DAG: GUID {{.*}} is globalfunc2
|
|
|
|
; GUID-DAG: GUID {{.*}} is P
|
|
|
|
; GUID-DAG: GUID {{.*}} is staticvar
|
|
|
|
; GUID-DAG: GUID {{.*}} is commonvar
|
|
|
|
; GUID-DAG: GUID {{.*}} is weakalias
|
|
|
|
; GUID-DAG: GUID {{.*}} is staticfunc
|
|
|
|
; GUID-DAG: GUID {{.*}} is weakfunc
|
|
|
|
; GUID-DAG: GUID {{.*}} is referenceglobals
|
|
|
|
; GUID-DAG: GUID {{.*}} is weakvar
|
|
|
|
; GUID-DAG: GUID {{.*}} is staticconstvar
|
|
|
|
; GUID-DAG: GUID {{.*}} is analias
|
|
|
|
; GUID-DAG: GUID {{.*}} is globalvar
|
|
|
|
; GUID-DAG: GUID {{.*}} is referencecommon
|
|
|
|
; GUID-DAG: GUID {{.*}} is linkoncealias
|
|
|
|
; GUID-DAG: GUID {{.*}} is callfuncptr
|
|
|
|
; GUID-DAG: GUID {{.*}} is linkoncefunc
|