File: funcimport_cutoff.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (49 lines) | stat: -rw-r--r-- 1,747 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
; Test to ensure that thin linking with -import-cutoff stops importing when
; expected.

; "-stats" and "-debug-only" require +Asserts.
; REQUIRES: asserts

; RUN: opt -module-summary %s -o %t.bc
; RUN: opt -module-summary %p/Inputs/funcimport_cutoff.ll -o %t2.bc
; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc

; First do with default options, which should import both foo and bar
; RUN: opt -passes=function-import -stats -print-imports -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=IMPORT

; Next try to restrict to 1 import. This should import just foo.
; 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

; Next try to restrict to 0 imports. This should not import.
; 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

define i32 @main() {
entry:
  call void @foo()
  call void @bar()
  ret i32 0
}

declare void @foo()
declare void @bar()

; Check -print-imports output
; IMPORT: Import foo
; IMPORT: Import bar
; IMPORT1: Import foo
; IMPORT1-NOT: Import bar
; NOIMPORT-NOT: Import foo
; NOIMPORT-NOT: Import bar

; Check -S output
; IMPORT-DAG: define available_externally void @foo()
; IMPORT-DAG: define available_externally void @bar()
; NOIMPORT-DAG: declare void @foo()
; NOIMPORT-DAG: declare void @bar()
; IMPORT1-DAG: define available_externally void @foo()
; IMPORT1-DAG: declare void @bar()

; Check -stats output
; IMPORT: 2 function-import - Number of functions imported
; IMPORT1: 1 function-import - Number of functions imported
; NOIMPORT-NOT: function-import - Number of functions imported