;; Basic FatLTO tests.
; REQUIRES: x86
; RUN: rm -rf %t && split-file %s %t && cd %t
;; Ensure that input files contain .llvm.lto section.
; RUN: llc a-LTO.ll --filetype=obj -o a-fatLTO.o --relocation-model=pic
; RUN: opt < a-LTO.ll --module-summary -o a-fatLTO.bc
; RUN: llvm-objcopy --add-section=.llvm.lto=a-fatLTO.bc --set-section-flags=.llvm.lto=exclude --set-section-type=.llvm.lto=0x6fff4c0c a-fatLTO.o
; RUN: llc main-LTO.ll --filetype=obj -o main-fatLTO.o --relocation-model=pic
; RUN: opt < main-LTO.ll --module-summary -o main-fatLTO.bc
; RUN: llvm-objcopy --add-section=.llvm.lto=main-fatLTO.bc --set-section-flags=.llvm.lto=exclude --set-section-type=.llvm.lto=0x6fff4c0c main-fatLTO.o
; RUN: llvm-readelf -S a-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
; RUN: llvm-readelf -S main-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
;; Make sure that the section flags are set correctly
; HAS_LLVM_LTO: Name Type Address Off Size ES Flg Lk Inf Al
; HAS_LLVM_LTO: .llvm.lto LLVM_LTO {{.*}} 00 WE 0 0 1
;; Final executable should not have .llvm.lto section no matter what the target is.
; RUN: ld.lld -o foo-fatLTO a-fatLTO.o main-fatLTO.o --fat-lto-objects
; RUN: llvm-readelf -S foo-fatLTO | FileCheck --check-prefix=CHECK-LTO-TARGET %s
;; Check that fat objects work w/ --start-lib.
; RUN: ld.lld -o foo-fatLTO.start_lib --start-lib a-fatLTO.o main-fatLTO.o --fat-lto-objects
; RUN: llvm-readelf -S foo-fatLTO.start_lib | FileCheck --check-prefix=CHECK-LTO-TARGET %s
;; Check if .llvm.lto section gets aggregated in LTO target.
; CHECK-LTO-TARGET: Name Type Address Off Size ES Flg Lk Inf Al
; CHECK-LTO-TARGET-NOT: .llvm.lto
;; Final executable should not have .llvm.lto section no matter what the target is.
; RUN: ld.lld -o foo-fatNoLTO a-fatLTO.o %/t/main-fatLTO.o
; RUN: llvm-readelf -S foo-fatNoLTO | FileCheck --check-prefix=CHECK-NON-LTO-TARGET %s
;; Check if .llvm.lto section gets aggregated in non-LTO target.
; CHECK-NON-LTO-TARGET: Name Type Address Off Size ES Flg Lk Inf Al
; CHECK-NON-LTO-TARGET-NOT: .llvm.lto
;; Check if the LTO target executable produced from FatLTO object file is
;; identical to the one produced from LTO modules.
; RUN: opt < a-LTO.ll --module-summary -o a-LTO.bc
; RUN: opt < main-LTO.ll --module-summary -o main-LTO.bc
; RUN: ld.lld -o foo-LTO a-LTO.bc main-LTO.bc
; RUN: cmp foo-fatLTO foo-LTO
;; Check if the no-LTO target executable produced from FatLTO object file is
;; identical to the one produced from regular object files.
; RUN: llc a-LTO.ll --filetype=obj -o a.o
; RUN: llc main-LTO.ll --filetype=obj -o main.o
; RUN: ld.lld -o foo-noLTO a.o main.o
; RUN: cmp foo-fatNoLTO foo-noLTO
;; Check archive support.
; RUN: llvm-ar rcs a.a a-fatLTO.o
; RUN: ld.lld -o foo-fatLTO.archive a.a main-LTO.bc --fat-lto-objects
; RUN: cmp foo-fatLTO.archive foo-LTO
;; Test FatLTO works with relocatable links using PIC objects, and that
;; SHT_LLVM_LTO sections are discarded.
; RUN: llvm-ar rcs fatLTO-pic.a a-fatLTO.o main-fatLTO.o
; RUN: llvm-readelf -S fatLTO-pic.a | FileCheck --check-prefix=HAS_LLVM_LTO %s
; RUN: ld.lld --whole-archive fatLTO-pic.a -r -o fatLTO-pic-relocatable.o
; RUN: llvm-readelf -S fatLTO-pic-relocatable.o | FileCheck --check-prefix=CHECK-NON-LTO-TARGET %s
;--- a-LTO.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noinline nounwind uwtable
define dso_local i32 @_start() #0 {
entry:
ret i32 0
}
attributes #0 = { noinline nounwind uwtable }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{i32 1, !"ThinLTO", i32 0}
!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
;--- main-LTO.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noinline nounwind uwtable
define dso_local i32 @main() #0 {
entry:
%retval = alloca i32, align 4
store i32 0, ptr %retval, align 4
%call = call i32 (...) @_start()
ret i32 %call
}
declare i32 @_start(...)
attributes #0 = { noinline nounwind uwtable }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{i32 1, !"ThinLTO", i32 0}
!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}