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
|
2017-02-03 02:42:25 +08:00
|
|
|
; RUN: opt -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
|
2017-02-03 02:42:25 +08:00
|
|
|
; RUN: opt -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
|
2018-03-12 18:30:50 +08:00
|
|
|
; RUN: opt -passes='function-import' -debug-only=function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=DUMP
|
|
|
|
; "-stats" and "-debug-only" require +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
|
2017-02-03 02:42:25 +08:00
|
|
|
; RUN: opt -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
|
|
|
|
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()
|
2018-11-15 03:30:13 +08:00
|
|
|
call void (...) @variadic_no_va_start()
|
|
|
|
call void (...) @variadic_va_start()
|
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
|
|
|
|
2017-12-16 08:18:12 +08:00
|
|
|
; External alias imported as available_externally copy of aliasee
|
|
|
|
; CHECK-DAG: define available_externally void @analias
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @analias(...) #1
|
|
|
|
|
2017-12-16 08:18:12 +08:00
|
|
|
; External alias imported as available_externally copy of aliasee
|
|
|
|
; (linkoncealias is an external alias to a linkonce_odr)
|
2015-11-27 03:22:59 +08:00
|
|
|
declare void @linkoncealias(...) #1
|
2017-12-16 08:18:12 +08:00
|
|
|
; CHECK-DAG: define available_externally void @linkoncealias()
|
2015-11-27 03:22:59 +08:00
|
|
|
|
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.
|
2018-01-18 10:08:23 +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.
|
2018-03-12 18:30:50 +08:00
|
|
|
; CHECK-DAG: @P.llvm.{{.*}} = available_externally hidden global void ()* null
|
2016-04-12 07:26:46 +08:00
|
|
|
; 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
|
2018-01-18 10:08:23 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !thinlto_src_module !0 {
|
|
|
|
; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()
|
2016-03-27 23:27:30 +08:00
|
|
|
|
2018-11-15 03:30:13 +08:00
|
|
|
; We can import variadic functions without a va_start, since the inliner
|
|
|
|
; can handle them.
|
|
|
|
; INSTLIMDEF-DAG: Import variadic_no_va_start
|
|
|
|
; CHECK-DAG: define available_externally void @variadic_no_va_start(...) !thinlto_src_module !0 {
|
|
|
|
declare void @variadic_no_va_start(...)
|
|
|
|
|
2018-12-01 13:11:46 +08:00
|
|
|
; We can import variadic functions with a va_start, since the inliner
|
|
|
|
; can sometimes handle them.
|
|
|
|
; CHECK-DAG: define available_externally void @variadic_va_start(...)
|
2018-11-15 03:30:13 +08:00
|
|
|
declare void @variadic_va_start(...)
|
2016-08-12 06:13:57 +08:00
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import globalfunc2
|
2018-12-01 13:11:46 +08:00
|
|
|
; INSTLIMDEF-DAG: 15 function-import - Number of functions imported
|
2018-03-12 18:30:50 +08:00
|
|
|
; INSTLIMDEF-DAG: 4 function-import - Number of global variables 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
|
2018-03-12 18:30:50 +08:00
|
|
|
|
|
|
|
; DUMP: Module [[M1:.*]] imports from 1 module
|
2018-12-01 13:11:46 +08:00
|
|
|
; DUMP-NEXT: 15 functions imported from [[M2:.*]]
|
2018-03-12 18:30:50 +08:00
|
|
|
; DUMP-NEXT: 4 vars imported from [[M2]]
|
2018-12-01 13:11:46 +08:00
|
|
|
; DUMP: Imported 15 functions for Module [[M1]]
|
2018-03-12 18:30:50 +08:00
|
|
|
; DUMP-NEXT: Imported 4 global variables for Module [[M1]]
|