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