xref: /llvm-project/llvm/test/Transforms/FunctionImport/adjustable_threshold.ll (revision a9af1b9a307780a39facd016c7329990d6cc5508)
1cee313d2SEric Christopher; Do setup work for all below tests: generate bitcode and combined index
2cee313d2SEric Christopher; RUN: opt -module-summary %s -o %t.bc
3cee313d2SEric Christopher; RUN: opt -module-summary %p/Inputs/adjustable_threshold.ll -o %t2.bc
4cee313d2SEric Christopher; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
5cee313d2SEric Christopher
6cee313d2SEric Christopher; Test import with default progressive instruction factor
7*a9af1b9aSFangrui Song; RUN: opt -passes=function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -S | FileCheck %s --check-prefix=INSTLIM-DEFAULT
8cee313d2SEric Christopher; INSTLIM-DEFAULT: call void @staticfunc2.llvm.
9cee313d2SEric Christopher
10cee313d2SEric Christopher; Test import with a reduced progressive instruction factor
11*a9af1b9aSFangrui Song; RUN: opt -passes=function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -import-instr-evolution-factor=0.5 -S | FileCheck %s --check-prefix=INSTLIM-PROGRESSIVE
12cee313d2SEric Christopher; INSTLIM-PROGRESSIVE-NOT: call void @staticfunc
13cee313d2SEric Christopher
14bf612458SYaxun (Sam) Liu; Test force import all
15*a9af1b9aSFangrui Song; RUN: opt -passes=function-import -summary-file %t3.thinlto.bc %t.bc \
16bf612458SYaxun (Sam) Liu; RUN:  -import-instr-limit=1 -force-import-all -S \
17bf612458SYaxun (Sam) Liu; RUN:  | FileCheck %s --check-prefix=IMPORTALL
18bf612458SYaxun (Sam) Liu; IMPORTALL-DAG: define available_externally void @globalfunc1()
19bf612458SYaxun (Sam) Liu; IMPORTALL-DAG: define available_externally void @trampoline()
20bf612458SYaxun (Sam) Liu; IMPORTALL-DAG: define available_externally void @largefunction()
21bf612458SYaxun (Sam) Liu; IMPORTALL-DAG: define available_externally hidden void @staticfunc2.llvm.0()
22bf612458SYaxun (Sam) Liu; IMPORTALL-DAG: define available_externally void @globalfunc2()
23cee313d2SEric Christopher
24cee313d2SEric Christopherdeclare void @globalfunc1()
25cee313d2SEric Christopherdeclare void @globalfunc2()
26cee313d2SEric Christopher
27cee313d2SEric Christopherdefine void @entry() {
28cee313d2SEric Christopherentry:
29cee313d2SEric Christopher; Call site are processed in reversed order!
30cee313d2SEric Christopher
31cee313d2SEric Christopher; On the direct call, we reconsider @largefunction with a higher threshold and
32cee313d2SEric Christopher; import it
33cee313d2SEric Christopher  call void @globalfunc2()
34cee313d2SEric Christopher; When importing globalfunc1, the threshold was limited and @largefunction was
35cee313d2SEric Christopher; not imported.
36cee313d2SEric Christopher  call void @globalfunc1()
37cee313d2SEric Christopher  ret void
38cee313d2SEric Christopher}
39cee313d2SEric Christopher
40