2015-11-24 14:07:49 +08:00
|
|
|
; Do setup work for all below tests: generate bitcode and combined index
|
|
|
|
; RUN: llvm-as -function-summary %s -o %t.bc
|
|
|
|
; RUN: llvm-as -function-summary %p/Inputs/funcimport.ll -o %t2.bc
|
|
|
|
; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
|
|
|
|
|
|
|
|
; Do the import now
|
2015-11-25 06:55:46 +08:00
|
|
|
; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
|
|
|
|
|
|
|
|
; Test import with smaller instruction limit
|
|
|
|
; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
|
|
|
|
; INSTLIM5-NOT: @staticfunc.llvm.2
|
2015-11-24 14:07:49 +08:00
|
|
|
|
|
|
|
define i32 @main() #0 {
|
|
|
|
entry:
|
|
|
|
call void (...) @weakalias()
|
|
|
|
call void (...) @analias()
|
|
|
|
%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
|
|
|
|
; CHECK-DAG: declare extern_weak void @weakalias()
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @weakalias(...) #1
|
2015-11-25 00:10:43 +08:00
|
|
|
|
|
|
|
; Aliases import the aliasee function
|
|
|
|
; CHECK-DAG: @analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
|
|
|
|
; CHECK-DAG: define available_externally void @globalfunc2()
|
2015-11-24 14:07:49 +08:00
|
|
|
declare void @analias(...) #1
|
|
|
|
|
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.
|
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
|
|
|
|
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.
|
|
|
|
; CHECK-DAG: define available_externally void @globalfunc1()
|
|
|
|
|
2015-11-24 14:07:49 +08:00
|
|
|
; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i)
|
|
|
|
declare i32 @referencecommon(...) #1
|
|
|
|
|
|
|
|
; CHECK-DAG: define available_externally void @setfuncptr()
|
|
|
|
declare void @setfuncptr(...) #1
|
|
|
|
|
|
|
|
; 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.
|
|
|
|
; CHECK-DAG: @P.llvm.2 = available_externally hidden global void ()* null
|
|
|
|
; 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
|
|
|
|
|