|
| 1 | +;; Basic FatLTO tests. |
| 2 | +; REQUIRES: x86 |
| 3 | + |
| 4 | +; RUN: rm -rf %t && split-file %s %t |
| 5 | + |
| 6 | +;; Ensure that input files contain .llvm.lto section. |
| 7 | +; RUN: llc %t/a-LTO.ll --filetype=obj -o %t/a-fatLTO.o |
| 8 | +; RUN: opt < %t/a-LTO.ll --module-summary -o %t/a-fatLTO.bc |
| 9 | +; RUN: llvm-objcopy --add-section=.llvm.lto=%t/a-fatLTO.bc --set-section-flags=.llvm.lto=exclude %t/a-fatLTO.o |
| 10 | + |
| 11 | +; RUN: llc %t/main-LTO.ll --filetype=obj -o %t/main-fatLTO.o |
| 12 | +; RUN: opt < %t/main-LTO.ll --module-summary -o %t/main-fatLTO.bc |
| 13 | +; RUN: llvm-objcopy --add-section=.llvm.lto=%t/main-fatLTO.bc --set-section-flags=.llvm.lto=exclude %t/main-fatLTO.o |
| 14 | + |
| 15 | +;; Final executable should not have .llvm.lto section no matter what the target is. |
| 16 | +; RUN: ld.lld -o %t/foo-fatLTO %t/a-fatLTO.o %t/main-fatLTO.o --fat-lto-objects |
| 17 | +; RUN: llvm-readobj -S %t/foo-fatLTO | FileCheck --check-prefix=CHECK-LTO-TARGET %s |
| 18 | + |
| 19 | +;; Check that fat objects work w/ --start-lib. |
| 20 | +; RUN: ld.lld -o %t/foo-fatLTO.start_lib --start-lib %t/a-fatLTO.o %t/main-fatLTO.o --fat-lto-objects |
| 21 | +; RUN: llvm-readobj -S %t/foo-fatLTO.start_lib | FileCheck --check-prefix=CHECK-LTO-TARGET %s |
| 22 | + |
| 23 | +;; Check if .llvm.lto section gets aggregated in LTO target. |
| 24 | +; CHECK-LTO-TARGET-NOT: Name: .llvm.lto |
| 25 | + |
| 26 | +;; Final executable should not have .llvm.lto section no matter what the target is. |
| 27 | +; RUN: ld.lld -o %t/foo-fatNoLTO %t/a-fatLTO.o %/t/main-fatLTO.o |
| 28 | +; RUN: llvm-readobj -S %t/foo-fatNoLTO | FileCheck --check-prefix=CHECK-NON-LTO-TARGET %s |
| 29 | + |
| 30 | +;; Check if .llvm.lto section gets aggregated in non-LTO target. |
| 31 | +; CHECK-NON-LTO-TARGET-NOT: Name: .llvm.lto |
| 32 | + |
| 33 | +;; Check if the LTO target executable produced from FatLTO object file is |
| 34 | +;; identical to the one produced from LTO modules. |
| 35 | +; RUN: opt < %t/a-LTO.ll --module-summary -o %t/a-LTO.bc |
| 36 | +; RUN: opt < %t/main-LTO.ll --module-summary -o %t/main-LTO.bc |
| 37 | +; RUN: ld.lld -o %t/foo-LTO %t/a-LTO.bc %t/main-LTO.bc |
| 38 | +; RUN: cmp %t/foo-fatLTO %t/foo-LTO |
| 39 | + |
| 40 | +;; Check if the no-LTO target executable produced from FatLTO object file is |
| 41 | +;; identical to the one produced from regular object files. |
| 42 | +; RUN: llc %t/a-LTO.ll --filetype=obj -o %t/a.o |
| 43 | +; RUN: llc %t/main-LTO.ll --filetype=obj -o %t/main.o |
| 44 | +; RUN: ld.lld -o %t/foo-noLTO %t/a.o %t/main.o |
| 45 | +; RUN: cmp %t/foo-fatNoLTO %t/foo-noLTO |
| 46 | + |
| 47 | +;; Check archive support. |
| 48 | +; RUN: llvm-ar rcs %t/a.a %t/a-fatLTO.o |
| 49 | +; RUN: ld.lld -o %t/foo-fatLTO.archive %t/a.a %t/main-LTO.bc --fat-lto-objects |
| 50 | +; RUN: cmp %t/foo-fatLTO.archive %t/foo-LTO |
| 51 | + |
| 52 | +;--- a-LTO.ll |
| 53 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 54 | +target triple = "x86_64-unknown-linux-gnu" |
| 55 | + |
| 56 | +; Function Attrs: noinline nounwind uwtable |
| 57 | +define dso_local i32 @_start() #0 { |
| 58 | +entry: |
| 59 | + ret i32 0 |
| 60 | +} |
| 61 | + |
| 62 | +attributes #0 = { noinline nounwind uwtable } |
| 63 | + |
| 64 | +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6} |
| 65 | + |
| 66 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 67 | +!1 = !{i32 7, !"PIC Level", i32 2} |
| 68 | +!2 = !{i32 7, !"PIE Level", i32 2} |
| 69 | +!3 = !{i32 7, !"uwtable", i32 2} |
| 70 | +!4 = !{i32 7, !"frame-pointer", i32 2} |
| 71 | +!5 = !{i32 1, !"ThinLTO", i32 0} |
| 72 | +!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1} |
| 73 | + |
| 74 | +;--- main-LTO.ll |
| 75 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 76 | +target triple = "x86_64-unknown-linux-gnu" |
| 77 | + |
| 78 | +; Function Attrs: noinline nounwind uwtable |
| 79 | +define dso_local i32 @main() #0 { |
| 80 | +entry: |
| 81 | + %retval = alloca i32, align 4 |
| 82 | + store i32 0, ptr %retval, align 4 |
| 83 | + %call = call i32 (...) @_start() |
| 84 | + ret i32 %call |
| 85 | +} |
| 86 | + |
| 87 | +declare i32 @_start(...) |
| 88 | + |
| 89 | +attributes #0 = { noinline nounwind uwtable } |
| 90 | + |
| 91 | +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6} |
| 92 | + |
| 93 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 94 | +!1 = !{i32 7, !"PIC Level", i32 2} |
| 95 | +!2 = !{i32 7, !"PIE Level", i32 2} |
| 96 | +!3 = !{i32 7, !"uwtable", i32 2} |
| 97 | +!4 = !{i32 7, !"frame-pointer", i32 2} |
| 98 | +!5 = !{i32 1, !"ThinLTO", i32 0} |
| 99 | +!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1} |
0 commit comments