[PATCH] D88094: [lld][test][ELF] Expand a couple of test cases for LTO behaviour

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:41:58 PDT 2020


jhenderson created this revision.
jhenderson added reviewers: grimar, MaskRay, ruiu.
Herald added subscribers: dexonsmith, steven_wu, hiraditya, inglorion, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
jhenderson requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88094

Files:
  lld/test/ELF/lto/weak.ll
  lld/test/ELF/reproduce-lto.s


Index: lld/test/ELF/reproduce-lto.s
===================================================================
--- lld/test/ELF/reproduce-lto.s
+++ lld/test/ELF/reproduce-lto.s
@@ -6,5 +6,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
Index: lld/test/ELF/lto/weak.ll
===================================================================
--- lld/test/ELF/lto/weak.ll
+++ 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/1.ll -o %t1.bc
+; RUN: llvm-as %t/2.ll -o %t2.bc
+; RUN: llc %t/4.ll -o %t4.o -filetype=obj
+
+; RUN: ld.lld %t1.bc %t2.bc -o %t.so -shared
+; RUN: llvm-readobj --symbols %t.so | FileCheck %s -DSIZE=1
+
+; RUN: ld.lld %t2.bc %t1.bc -o %t2.so -shared
+; RUN: llvm-readobj --symbols %t2.so | FileCheck %s -DSIZE=2
+
+; RUN: ld.lld %t1.bc %t4.o -o %t3.so -shared
+; RUN: llvm-readobj --symbols %t3.so | FileCheck %s -DSIZE=1
 
-define weak void @f() {
-  ret void
-}
+; RUN: ld.lld %t4.o %t1.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
+
+;--- 1.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"
+
+ at a = weak global i8 1
+
+;--- 2.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"
+
+ at a = weak global i16 1
+
+;--- 4.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"
+
+ at a = weak global i32 1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88094.293441.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200922/996aacbd/attachment.bin>


More information about the llvm-commits mailing list