xref: /llvm-project/llvm/test/Transforms/FunctionImport/funcimport_cutoff.ll (revision a9af1b9a307780a39facd016c7329990d6cc5508)
1; Test to ensure that thin linking with -import-cutoff stops importing when
2; expected.
3
4; "-stats" and "-debug-only" require +Asserts.
5; REQUIRES: asserts
6
7; RUN: opt -module-summary %s -o %t.bc
8; RUN: opt -module-summary %p/Inputs/funcimport_cutoff.ll -o %t2.bc
9; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
10
11; First do with default options, which should import both foo and bar
12; RUN: opt -passes=function-import -stats -print-imports -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=IMPORT
13
14; Next try to restrict to 1 import. This should import just foo.
15; RUN: opt -import-cutoff=1 -passes=function-import -stats -print-imports -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=IMPORT1
16
17; Next try to restrict to 0 imports. This should not import.
18; RUN: opt -import-cutoff=0 -passes=function-import -stats -print-imports -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=NOIMPORT
19
20define i32 @main() {
21entry:
22  call void @foo()
23  call void @bar()
24  ret i32 0
25}
26
27declare void @foo()
28declare void @bar()
29
30; Check -print-imports output
31; IMPORT: Import foo
32; IMPORT: Import bar
33; IMPORT1: Import foo
34; IMPORT1-NOT: Import bar
35; NOIMPORT-NOT: Import foo
36; NOIMPORT-NOT: Import bar
37
38; Check -S output
39; IMPORT-DAG: define available_externally void @foo()
40; IMPORT-DAG: define available_externally void @bar()
41; NOIMPORT-DAG: declare void @foo()
42; NOIMPORT-DAG: declare void @bar()
43; IMPORT1-DAG: define available_externally void @foo()
44; IMPORT1-DAG: declare void @bar()
45
46; Check -stats output
47; IMPORT: 2 function-import - Number of functions imported
48; IMPORT1: 1 function-import - Number of functions imported
49; NOIMPORT-NOT: function-import - Number of functions imported
50