diff options
author | James Henderson <james.henderson@sony.com> | 2020-09-22 14:36:53 +0100 |
---|---|---|
committer | James Henderson <james.henderson@sony.com> | 2020-09-24 11:49:20 +0100 |
commit | a4e42601d44b39fb0b2782344f5ed4ea53de5f20 (patch) | |
tree | 1f2316d2e0eb1767560885a586eed129e9027d34 /lld | |
parent | 590cc068c160f3b623d47fb34fd1d26848cb0e0a (diff) | |
download | llvm-a4e42601d44b39fb0b2782344f5ed4ea53de5f20.zip llvm-a4e42601d44b39fb0b2782344f5ed4ea53de5f20.tar.gz llvm-a4e42601d44b39fb0b2782344f5ed4ea53de5f20.tar.bz2 |
[lld][ELF][test] Add a couple of test cases for LTO behaviour
This patch expands two LTO test cases to check other aspects.
1) weak.ll has been expanded to show that it doesn't matter whether the
first appearance of a weak symbol appears in a bitcode file or native
object - that one is picked.
2) reproduce-lto.ll has been expanded to show that the bitcode files are
stored in the reproduce package and that intermediate files (such as
the LTO-compiled object) are not.
Differential Revision: https://reviews.llvm.org/D88094
Reviewed by: grimar, MaskRay
Diffstat (limited to 'lld')
-rw-r--r-- | lld/test/ELF/lto/weak.ll | 52 | ||||
-rw-r--r-- | lld/test/ELF/reproduce-lto.s | 11 |
2 files changed, 48 insertions, 15 deletions
diff --git a/lld/test/ELF/lto/weak.ll b/lld/test/ELF/lto/weak.ll index d2891a9..4e9a170 100644 --- a/lld/test/ELF/lto/weak.ll +++ b/lld/test/ELF/lto/weak.ll @@ -1,22 +1,48 @@ ; REQUIRES: x86 -;; Test weak symbols are supported in LTO. +;; Test weak symbols are supported in LTO. The first definition should be +;; used regardless of whether it is from a bitcode file or native object. -; RUN: llvm-as %s -o %t.o -; RUN: ld.lld %t.o %t.o -o %t.so -shared -; RUN: llvm-readobj --symbols %t.so | FileCheck %s +; RUN: split-file %s %t -target triple = "x86_64-unknown-linux-gnu" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; RUN: llvm-as %t/size1.ll -o %t-size1.bc +; RUN: llvm-as %t/size2.ll -o %t-size2.bc +; RUN: llc %t/size4.ll -o %t-size4.o -filetype=obj + +; RUN: ld.lld %t-size1.bc %t-size2.bc -o %t.so -shared +; RUN: llvm-readobj --symbols %t.so | FileCheck %s -DSIZE=1 + +; RUN: ld.lld %t-size2.bc %t-size1.bc -o %t2.so -shared +; RUN: llvm-readobj --symbols %t2.so | FileCheck %s -DSIZE=2 + +; RUN: ld.lld %t-size1.bc %t-size4.o -o %t3.so -shared +; RUN: llvm-readobj --symbols %t3.so | FileCheck %s -DSIZE=1 -define weak void @f() { - ret void -} +; RUN: ld.lld %t-size4.o %t-size1.bc -o %t4.so -shared +; RUN: llvm-readobj --symbols %t4.so | FileCheck %s -DSIZE=4 -; CHECK: Name: f +; CHECK: Name: a ; CHECK-NEXT: Value: -; CHECK-NEXT: Size: 1 +; CHECK-NEXT: Size: [[SIZE]] ; CHECK-NEXT: Binding: Weak -; CHECK-NEXT: Type: Function +; CHECK-NEXT: Type: Object ; CHECK-NEXT: Other: 0 -; CHECK-NEXT: Section: .text +; CHECK-NEXT: Section: .data + +;--- size1.ll +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + +@a = weak global i8 1 + +;--- size2.ll +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + +@a = weak global i16 1 + +;--- size4.ll +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + +@a = weak global i32 1 diff --git a/lld/test/ELF/reproduce-lto.s b/lld/test/ELF/reproduce-lto.s index e7c3ece..36838f2 100644 --- a/lld/test/ELF/reproduce-lto.s +++ b/lld/test/ELF/reproduce-lto.s @@ -1,4 +1,7 @@ # REQUIRES: x86 +## Show that bitcode files and inputs to LTO-related options are stored in the +## reproduce package and that intermediate files (such as the LTO-compiled +## object) are not. # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir/build1 @@ -6,5 +9,9 @@ # RUN: echo > %t.dir/build1/empty_profile.txt # RUN: cd %t.dir # RUN: ld.lld build1/foo.o -o /dev/null --reproduce repro1.tar --lto-sample-profile=%t.dir/build1/empty_profile.txt -# RUN: tar tvf repro1.tar | FileCheck %s -# CHECK: repro1/{{.*}}/empty_profile.txt +# RUN: tar tvf repro1.tar | FileCheck %s --implicit-check-not={{.}} + +# CHECK-DAG: {{.*}} repro1/{{.*}}/empty_profile.txt +# CHECK-DAG: {{.*}} repro1/response.txt +# CHECK-DAG: {{.*}} repro1/version.txt +# CHECK-DAG: {{.*}} repro1/{{.*}}/foo.o |