2015-11-24 14:07:49 +08:00
|
|
|
; Do setup work for all below tests: generate bitcode and combined index
|
2016-03-15 08:04:37 +08:00
|
|
|
; RUN: llvm-as -module-summary %s -o %t.bc
|
|
|
|
; RUN: llvm-as -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-03-27 23:27:30 +08:00
|
|
|
; RUN: opt -function-import -stats -print-imports -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.
|
|
|
|
; REQUIRES: asserts
|
2015-11-25 06:55:46 +08:00
|
|
|
|
|
|
|
; Test import with smaller instruction limit
|
2016-03-26 13:40:34 +08:00
|
|
|
; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
|
2015-11-25 06:55:46 +08:00
|
|
|
; INSTLIM5-NOT: @staticfunc.llvm.2
|
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()
|
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
|
|
|
|
|
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 linkoncealias
|
|
|
|
; INSTLIMDEF-DAG: Import linkoncefunc
|
2015-11-27 03:22:59 +08:00
|
|
|
; CHECK-DAG: define linkonce_odr void @linkoncefunc()
|
|
|
|
; CHECK-DAG: @linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referencestatics
|
2015-11-25 06:55:46 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i)
|
|
|
|
; 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
|
2015-11-25 06:55:46 +08:00
|
|
|
; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.2()
|
|
|
|
; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.2()
|
2015-11-25 03:55:04 +08:00
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referenceglobals
|
2015-11-24 14:07:49 +08:00
|
|
|
; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i)
|
|
|
|
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
|
2015-11-25 03:55:04 +08:00
|
|
|
; CHECK-DAG: define available_externally void @globalfunc1()
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import referencecommon
|
2015-11-24 14:07:49 +08:00
|
|
|
; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i)
|
|
|
|
declare i32 @referencecommon(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import setfuncptr
|
2015-11-24 14:07:49 +08:00
|
|
|
; CHECK-DAG: define available_externally void @setfuncptr()
|
|
|
|
declare void @setfuncptr(...) #1
|
|
|
|
|
2016-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import callfuncptr
|
2015-11-24 14:07:49 +08:00
|
|
|
; CHECK-DAG: define available_externally void @callfuncptr()
|
|
|
|
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-03-19 08:40:31 +08:00
|
|
|
; CHECK-DAG: @P.llvm.2 = external hidden global void ()*
|
2015-11-25 03:46:58 +08:00
|
|
|
; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.2,
|
|
|
|
; CHECK-DAG: store void ()* @staticfunc2.llvm.2, void ()** @P.llvm.2,
|
|
|
|
|
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-03-27 23:27:30 +08:00
|
|
|
; INSTLIMDEF-DAG: Import funcwithpersonality
|
2016-01-12 08:24:24 +08:00
|
|
|
; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.2() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
|
|
|
; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.2()
|
2016-03-27 23:27:30 +08:00
|
|
|
|
|
|
|
; INSTLIMDEF-DAG: Import globalfunc2
|
2016-03-27 23:36:43 +08:00
|
|
|
; INSTLIMDEF-DAG: 11 function-import - Number of functions imported
|
2016-04-05 02:52:58 +08:00
|
|
|
|
|
|
|
; The GUID values should be stable unless the global identifier scheme
|
|
|
|
; is changed.
|
|
|
|
; GUID-DAG: GUID 18438612909910340889 is weakalias
|
|
|
|
; GUID-DAG: GUID 10419849736188691048 is referenceglobals
|
|
|
|
; GUID-DAG: GUID 9779356664709680872 is weakfunc
|
|
|
|
; GUID-DAG: GUID 15822663052811949562 is main
|
|
|
|
; GUID-DAG: GUID 1794834399867852914 is referencecommon
|
|
|
|
; GUID-DAG: GUID 12695095382722328222 is analias
|
|
|
|
; GUID-DAG: GUID 11460932053523480915 is referencestatics
|
|
|
|
; GUID-DAG: GUID 17082925359558765443 is linkoncealias
|
|
|
|
; GUID-DAG: GUID 16956293738471118660 is setfuncptr
|
|
|
|
; GUID-DAG: GUID 800887449839734011 is callfuncptr
|
|
|
|
; GUID-DAG: GUID 12108029313449967842 is funcwithpersonality
|
|
|
|
; GUID-DAG: GUID 16956293738471118660 is setfuncptr
|
|
|
|
; GUID-DAG: GUID 15894399990123115248 is staticfunc2
|
|
|
|
; GUID-DAG: GUID 1233668236132380018 is __gxx_personality_v0
|
|
|
|
; GUID-DAG: GUID 11460932053523480915 is referencestatics
|
|
|
|
; GUID-DAG: GUID 8332887114342655934 is globalfunc1
|
|
|
|
; GUID-DAG: GUID 2602152165807499502 is globalfunc2
|
|
|
|
; GUID-DAG: GUID 9342344237287280920 is P
|
|
|
|
; GUID-DAG: GUID 17578217388980876465 is staticvar
|
|
|
|
; GUID-DAG: GUID 3013670425691502549 is commonvar
|
|
|
|
; GUID-DAG: GUID 18438612909910340889 is weakalias
|
|
|
|
; GUID-DAG: GUID 13921022463002872889 is staticfunc
|
|
|
|
; GUID-DAG: GUID 9779356664709680872 is weakfunc
|
|
|
|
; GUID-DAG: GUID 10419849736188691048 is referenceglobals
|
|
|
|
; GUID-DAG: GUID 8769477226392140800 is weakvar
|
|
|
|
; GUID-DAG: GUID 16489816843137310249 is staticconstvar
|
|
|
|
; GUID-DAG: GUID 12695095382722328222 is analias
|
|
|
|
; GUID-DAG: GUID 12887606300320728018 is globalvar
|
|
|
|
; GUID-DAG: GUID 1794834399867852914 is referencecommon
|
|
|
|
; GUID-DAG: GUID 17082925359558765443 is linkoncealias
|
|
|
|
; GUID-DAG: GUID 800887449839734011 is callfuncptr
|
|
|
|
; GUID-DAG: GUID 7812846502172333492 is linkoncefunc
|