Debian Codegraph @

lld/test/COFF/fatlto/fatlto.test

raw
1 ;; Basic FatLTO tests.
2 ; REQUIRES: x86
3
4 ; RUN: rm -rf %t && split-file %s %t && cd %t
5
6 ;; Ensure that input files contain .llvm.lto section.
7 ; RUN: llc a-LTO.ll --filetype=obj -o a-fatLTO.o --relocation-model=pic
8 ; RUN: opt < a-LTO.ll --module-summary -o a-fatLTO.bc
9 ; RUN: llvm-objcopy --add-section=.llvm.lto=a-fatLTO.bc --set-section-flags=.llvm.lto=exclude a-fatLTO.o
10
11 ; RUN: llc main-LTO.ll --filetype=obj -o main-fatLTO.o --relocation-model=pic
12 ; RUN: opt < main-LTO.ll --module-summary -o main-fatLTO.bc
13 ; RUN: llvm-objcopy --add-section=.llvm.lto=main-fatLTO.bc --set-section-flags=.llvm.lto=exclude main-fatLTO.o
14
15 ; RUN: llvm-readobj --sections a-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
16 ; RUN: llvm-readobj --sections main-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
17
18 ;; Make sure that the section flags are set correctly
19 ; HAS_LLVM_LTO: Name: .llvm.lto (2F 34 00 00 00 00 00 00)
20 ; HAS_LLVM_LTO: Characteristics [
21 ; HAS_LLVM_LTO-SAME: (0xC0000800)
22 ; HAS_LLVM_LTO-NEXT: IMAGE_SCN_LNK_REMOVE (0x800)
23 ; HAS_LLVM_LTO-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
24 ; HAS_LLVM_LTO-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000)
25 ; HAS_LLVM_LTO-NEXT: ]
26
27 ;; Final executable should not have .llvm.lto section no matter what the target is.
28 ; RUN: lld-link /timestamp:0 /out:foo-fatLTO /entry:main a-fatLTO.o main-fatLTO.o -fat-lto-objects
29 ; RUN: llvm-readobj --sections foo-fatLTO | FileCheck --check-prefix=CHECK-LTO-TARGET %s
30
31 ;; Check that fat objects work w/ --start-lib.
32 ; RUN: lld-link /out:foo-fatLTO.start_lib /entry:main -start-lib a-fatLTO.o main-fatLTO.o -fat-lto-objects
33 ; RUN: llvm-readobj --sections foo-fatLTO.start_lib | FileCheck --check-prefix=CHECK-LTO-TARGET %s
34
35 ;; Check if .llvm.lto section gets aggregated in LTO target.
36 ; CHECK-LTO-TARGET-NOT: Name: .llvm.lto
37
38 ;; Final executable should not have .llvm.lto section no matter what the target is.
39 ; RUN: lld-link /timestamp:0 /out:foo-fatNoLTO /entry:main a-fatLTO.o %/t/main-fatLTO.o
40 ; RUN: llvm-readobj --sections foo-fatNoLTO | FileCheck --check-prefix=CHECK-NON-LTO-TARGET %s
41
42 ;; Check if .llvm.lto section gets aggregated in non-LTO target.
43 ; CHECK-NON-LTO-TARGET-NOT: Name: .llvm.lto
44
45 ;; Check if the LTO target executable produced from FatLTO object file is
46 ;; identical to the one produced from LTO modules.
47 ; RUN: opt < a-LTO.ll --module-summary -o a-LTO.bc
48 ; RUN: opt < main-LTO.ll --module-summary -o main-LTO.bc
49 ; RUN: lld-link /timestamp:0 /out:foo-LTO /entry:main a-LTO.bc main-LTO.bc
50 ; RUN: cmp foo-fatLTO foo-LTO
51
52 ;; Check if the no-LTO target executable produced from FatLTO object file is
53 ;; identical to the one produced from regular object files.
54 ; RUN: llc a-LTO.ll --filetype=obj -o a.o
55 ; RUN: llc main-LTO.ll --filetype=obj -o main.o
56 ; RUN: lld-link /timestamp:0 /out:foo-noLTO /entry:main a.o main.o
57 ; RUN: cmp foo-fatNoLTO foo-noLTO
58
59 ;; Check archive support.
60 ; RUN: llvm-ar rcs a.a a-fatLTO.o
61 ; RUN: lld-link /timestamp:0 /out:foo-fatLTO.archive /entry:main /wholearchive a.a main-LTO.bc -fat-lto-objects
62 ; RUN: cmp foo-fatLTO.archive foo-LTO
63
64 ;--- a-LTO.ll
65 target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
66 target triple = "i386-pc-windows-msvc19.33.0"
67
68 ; Function Attrs: noinline nounwind uwtable
69 define dso_local i32 @_start() #0 {
70 entry:
71 ret i32 0
72 }
73
74 attributes #0 = { noinline nounwind uwtable }
75
76 !llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
77
78 !0 = !{i32 1, !"NumRegisterParameters", i32 0}
79 !1 = !{i32 2, !"Debug Info Version", i32 3}
80 !2 = !{i32 1, !"wchar_size", i32 2}
81 !3 = !{i32 7, !"frame-pointer", i32 2}
82 !4 = !{i32 1, !"MaxTLSAlign", i32 65536}
83 !5 = !{i32 1, !"ThinLTO", i32 0}
84 !6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
85
86 ;--- main-LTO.ll
87 target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
88 target triple = "i386-pc-windows-msvc19.33.0"
89
90 ; Function Attrs: noinline nounwind uwtable
91 define dso_local i32 @main() #0 {
92 entry:
93 %retval = alloca i32, align 4
94 store i32 0, ptr %retval, align 4
95 %call = call i32 (...) @_start()
96 ret i32 %call
97 }
98
99 declare i32 @_start(...)
100
101 attributes #0 = { noinline nounwind uwtable }
102
103 !llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
104
105 !0 = !{i32 1, !"NumRegisterParameters", i32 0}
106 !1 = !{i32 2, !"Debug Info Version", i32 3}
107 !2 = !{i32 1, !"wchar_size", i32 2}
108 !3 = !{i32 7, !"frame-pointer", i32 2}
109 !4 = !{i32 1, !"MaxTLSAlign", i32 65536}
110 !5 = !{i32 1, !"ThinLTO", i32 0}
111 !6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}