[lld] [lld][NFC] Precommit test for ld -r links FatLTO PIC objects (PR #92817)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 14:10:59 PDT 2024
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/92817
>From 7ae42667cab825e3a89df9b8ebff1b37dc155f79 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 20 May 2024 13:48:00 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
=?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
lld/test/ELF/fatlto/fatlto.test | 41 +++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lld/test/ELF/fatlto/fatlto.test b/lld/test/ELF/fatlto/fatlto.test
index edf4ef2da2b88..2b9c41d5f5587 100644
--- a/lld/test/ELF/fatlto/fatlto.test
+++ b/lld/test/ELF/fatlto/fatlto.test
@@ -49,6 +49,25 @@
; RUN: ld.lld -o %t/foo-fatLTO.archive %t/a.a %t/main-LTO.bc --fat-lto-objects
; RUN: cmp %t/foo-fatLTO.archive %t/foo-LTO
+;; Test FatLTO works with relocatable links using PIC objects
+;; Currently, with PIC relocatable links, FatLTO sections are treated as
+;; orphan sections and incorrectly concatenated together. This test verifies
+;; the current behavior, but should be fixed to either merge those sections
+;; correctly, or to drop them altogether.
+; RUN: opt < %t/a-LTO.ll -passes="embed-bitcode<thinlto;emit-summary>" | llc --relocation-model=pic --filetype=obj -o %t/a-fat-pic.o
+; RUN: llvm-readobj -S %t/a-fat-pic.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
+
+; RUN: opt < %t/b-LTO.ll -passes="embed-bitcode<thinlto;emit-summary>" | llc --relocation-model=pic --filetype=obj -o %t/b-fat-pic.o
+; RUN: llvm-readobj -S %t/b-fat-pic.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
+
+; RUN: llvm-ar rcs %t/fat.archive %t/a-fat-pic.o %t/b-fat-pic.o
+; RUN: llvm-readobj -S %t/fat.pic.archive | FileCheck --check-prefix=HAS_LLVM_LTO %s
+
+; RUN: ld.lld --whole-archive %t/fat.pic.archive -r -o %t/fat-relocatable.o
+; RUN: llvm-readobj -S %t/fat-pic-relocatable.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
+
+; HAS_LLVM_LTO: Name: .llvm.lto
+
;--- 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"
@@ -71,6 +90,28 @@ attributes #0 = { noinline nounwind uwtable }
!5 = !{i32 1, !"ThinLTO", i32 0}
!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
+;--- b-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 @foo() #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"
>From c09de94c31e087cd812646db107d91b360abf35f Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 20 May 2024 14:10:46 -0700
Subject: [PATCH 2/2] Fix filename in RUN line
Created using spr 1.3.4
---
lld/test/ELF/fatlto/fatlto.test | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lld/test/ELF/fatlto/fatlto.test b/lld/test/ELF/fatlto/fatlto.test
index 2b9c41d5f5587..e250325dc54f4 100644
--- a/lld/test/ELF/fatlto/fatlto.test
+++ b/lld/test/ELF/fatlto/fatlto.test
@@ -60,10 +60,10 @@
; RUN: opt < %t/b-LTO.ll -passes="embed-bitcode<thinlto;emit-summary>" | llc --relocation-model=pic --filetype=obj -o %t/b-fat-pic.o
; RUN: llvm-readobj -S %t/b-fat-pic.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
-; RUN: llvm-ar rcs %t/fat.archive %t/a-fat-pic.o %t/b-fat-pic.o
+; RUN: llvm-ar rcs %t/fat.pic.archive %t/a-fat-pic.o %t/b-fat-pic.o
; RUN: llvm-readobj -S %t/fat.pic.archive | FileCheck --check-prefix=HAS_LLVM_LTO %s
-; RUN: ld.lld --whole-archive %t/fat.pic.archive -r -o %t/fat-relocatable.o
+; RUN: ld.lld --whole-archive %t/fat.pic.archive -r -o %t/fat-pic-relocatable.o
; RUN: llvm-readobj -S %t/fat-pic-relocatable.o | FileCheck --check-prefix=HAS_LLVM_LTO %s
; HAS_LLVM_LTO: Name: .llvm.lto
More information about the llvm-commits
mailing list