[lld] r371292 - [ELF][test] Improve LTO tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 01:20:09 PDT 2019
Author: maskray
Date: Sat Sep 7 01:20:09 2019
New Revision: 371292
URL: http://llvm.org/viewvc/llvm-project?rev=371292&view=rev
Log:
[ELF][test] Improve LTO tests
Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output
Added:
lld/trunk/test/ELF/lto/symbol-ordering-data.s
lld/trunk/test/ELF/lto/symbol-ordering-function.s
Removed:
lld/trunk/test/ELF/lto/data-ordering-lto.s
lld/trunk/test/ELF/lto/symbol-ordering-lto.s
Modified:
lld/trunk/test/ELF/lto/comdat2.ll
lld/trunk/test/ELF/lto/dynamic-list.ll
lld/trunk/test/ELF/lto/linker-script-symbols-ipo.ll
lld/trunk/test/ELF/lto/obj-path.ll
lld/trunk/test/ELF/lto/parallel-internalize.ll
lld/trunk/test/ELF/lto/shlib-undefined.ll
lld/trunk/test/ELF/lto/undefined-puts.ll
lld/trunk/test/ELF/lto/version-script.ll
lld/trunk/test/ELF/lto/version-script2.ll
lld/trunk/test/ELF/lto/visibility.ll
lld/trunk/test/ELF/lto/weak.ll
Modified: lld/trunk/test/ELF/lto/comdat2.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/comdat2.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/comdat2.ll (original)
+++ lld/trunk/test/ELF/lto/comdat2.ll Sat Sep 7 01:20:09 2019
@@ -1,4 +1,8 @@
; REQUIRES: x86
+
+;; Test we don't get "duplicate symbol" error when bitcode/regular object
+;; comdats are used together.
+
; RUN: llvm-as %s -o %t.o
; RUN: llvm-mc -triple=x86_64-pc-linux %p/Inputs/comdat.s -o %t2.o -filetype=obj
; RUN: ld.lld %t.o %t2.o -o %t.so -shared
@@ -18,7 +22,7 @@ define protected void @foo() comdat($c)
; CHECK: Symbol {
; CHECK: Name: foo
-; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global
; CHECK-NEXT: Type: Function
@@ -30,7 +34,7 @@ define protected void @foo() comdat($c)
; OTHER: Symbol {
; OTHER: Name: foo
-; OTHER-NEXT: Value: 0x1000
+; OTHER-NEXT: Value:
; OTHER-NEXT: Size: 0
; OTHER-NEXT: Binding: Global
; OTHER-NEXT: Type: None
Removed: lld/trunk/test/ELF/lto/data-ordering-lto.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/data-ordering-lto.s?rev=371291&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/data-ordering-lto.s (original)
+++ lld/trunk/test/ELF/lto/data-ordering-lto.s (removed)
@@ -1,28 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
-# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc
-
-# Set up the symbol file
-# RUN: echo "tin " > %t_order_lto.txt
-# RUN: echo "dipsy " >> %t_order_lto.txt
-# RUN: echo "pat " >> %t_order_lto.txt
-
-# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
-# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
-
-# Check that the order is tin -> dipsy -> pat.
-
-# CHECK: Symbol table '.symtab' contains 6 entries:
-# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
-# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
-# CHECK-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS {{.*}}.o
-# CHECK-NEXT: 2: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 1 _start
-# CHECK-NEXT: 3: 0000000000202004 4 OBJECT GLOBAL DEFAULT 2 dipsy
-# CHECK-NEXT: 4: 0000000000202008 4 OBJECT GLOBAL DEFAULT 2 pat
-# CHECK-NEXT: 5: 0000000000202000 4 OBJECT GLOBAL DEFAULT 2 tin
-
-.globl _start
-_start:
- movl $pat, %ecx
- movl $dipsy, %ebx
- movl $tin, %eax
Modified: lld/trunk/test/ELF/lto/dynamic-list.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/dynamic-list.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/dynamic-list.ll (original)
+++ lld/trunk/test/ELF/lto/dynamic-list.ll Sat Sep 7 01:20:09 2019
@@ -1,11 +1,14 @@
; REQUIRES: x86
+
+;; Test we parse dynamic lists before LTO, so symbols can be exported correctly.
+
; RUN: llvm-as %s -o %t.o
; RUN: echo "{ foo; };" > %t.list
; RUN: ld.lld -o %t --dynamic-list %t.list -pie %t.o
; RUN: llvm-readobj --dyn-syms %t | FileCheck %s
; CHECK: Name: foo
-; CHECK-NEXT: Value: 0x1010
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function
Modified: lld/trunk/test/ELF/lto/linker-script-symbols-ipo.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/linker-script-symbols-ipo.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/linker-script-symbols-ipo.ll (original)
+++ lld/trunk/test/ELF/lto/linker-script-symbols-ipo.ll Sat Sep 7 01:20:09 2019
@@ -8,17 +8,17 @@
; RUN: llvm-objdump -d %t3 | FileCheck %s --check-prefix=IPO
; IPO: Disassembly of section .text:
; IPO: _start:
-; IPO-NEXT: 201000: {{.*}} movl $1, %eax
-; IPO-NEXT: 201005: {{.*}} retq
+; IPO-NEXT: movl $1, %eax
+; IPO-NEXT: retq
;; Check that LTO does not do IPO for symbols assigned by script.
; RUN: ld.lld %t1.o %t2.o -o %t4 --script %t.script -save-temps
; RUN: llvm-objdump -d %t4 | FileCheck %s --check-prefix=NOIPO
; NOIPO: Disassembly of section .text:
; NOIPO: foo:
-; NOIPO-NEXT: {{.*}} movl $2, %eax
+; NOIPO-NEXT: movl $2, %eax
; NOIPO: _start:
-; NOIPO-NEXT: {{.*}} jmp -21 <foo>
+; NOIPO-NEXT: jmp -21 <foo>
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Modified: lld/trunk/test/ELF/lto/obj-path.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/obj-path.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/obj-path.ll (original)
+++ lld/trunk/test/ELF/lto/obj-path.ll Sat Sep 7 01:20:09 2019
@@ -6,16 +6,14 @@
; Test to ensure that obj-path creates the ELF file.
; RUN: rm -f %t4.o
; RUN: ld.lld --plugin-opt=obj-path=%t4.o -shared %t1.o %t2.o -o %t3
-; RUN: llvm-readobj --symbols %t3 | FileCheck %s
+; RUN: llvm-nm %t3 | FileCheck %s
; RUN: llvm-readobj -h %t4.o1 | FileCheck %s -check-prefix=ELF1
; RUN: llvm-readobj -h %t4.o2 | FileCheck %s -check-prefix=ELF2
; RUN: llvm-nm %t4.o1 2>&1 | FileCheck %s -check-prefix=NM1
; RUN: llvm-nm %t4.o2 2>&1 | FileCheck %s -check-prefix=NM2
-; CHECK: Name: g
-; CHECK-NEXT: Value: 0x1010
-; CHECK: Name: f
-; CHECK-NEXT: Value: 0x1000
+; CHECK: T f
+; CHECK-NEXT: T g
; NM1: T f
; ELF1: Format: ELF64-x86-64
Modified: lld/trunk/test/ELF/lto/parallel-internalize.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/parallel-internalize.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/parallel-internalize.ll (original)
+++ lld/trunk/test/ELF/lto/parallel-internalize.ll Sat Sep 7 01:20:09 2019
@@ -37,7 +37,7 @@
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: bar
-; CHECK-NEXT: Value: 0x201010
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Local (0x0)
; CHECK-NEXT: Type: Function (0x2)
@@ -48,7 +48,7 @@
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: foo
-; CHECK-NEXT: Value: 0x201000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function (0x2)
Modified: lld/trunk/test/ELF/lto/shlib-undefined.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/shlib-undefined.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/shlib-undefined.ll (original)
+++ lld/trunk/test/ELF/lto/shlib-undefined.ll Sat Sep 7 01:20:09 2019
@@ -7,7 +7,7 @@
; RUN: llvm-readobj --dyn-syms %t | FileCheck %s
; CHECK: Name: __progname
-; CHECK-NEXT: Value: 0x201010
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function
Added: lld/trunk/test/ELF/lto/symbol-ordering-data.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/symbol-ordering-data.s?rev=371292&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/symbol-ordering-data.s (added)
+++ lld/trunk/test/ELF/lto/symbol-ordering-data.s Sat Sep 7 01:20:09 2019
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+
+## Test we enable data sections for LTO so --symbol-ordering-fils is respected
+## for data symbols.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
+# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc
+
+# RUN: echo "tin " > %t_order_lto.txt
+# RUN: echo "dipsy " >> %t_order_lto.txt
+# RUN: echo "pat " >> %t_order_lto.txt
+
+# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t
+# RUN: llvm-nm -v %t | FileCheck %s
+
+# CHECK: D tin
+# CHECK-NEXT: D dipsy
+# CHECK-NEXT: D pat
+
+.globl _start
+_start:
+ movl $pat, %ecx
+ movl $dipsy, %ebx
+ movl $tin, %eax
Added: lld/trunk/test/ELF/lto/symbol-ordering-function.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/symbol-ordering-function.s?rev=371292&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/symbol-ordering-function.s (added)
+++ lld/trunk/test/ELF/lto/symbol-ordering-function.s Sat Sep 7 01:20:09 2019
@@ -0,0 +1,23 @@
+# REQUIRES: x86
+
+## Test we enable function sections for LTO so --symbol-ordering-fils is respected
+## for function symbols.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
+# RUN: llvm-as %p/Inputs/symbol-ordering-lto.ll -o %t.bc
+
+# RUN: echo "tin " > %t_order_lto.txt
+# RUN: echo "_start " >> %t_order_lto.txt
+# RUN: echo "pat " >> %t_order_lto.txt
+
+# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t
+# RUN: llvm-nm -v %t | FileCheck %s
+
+# CHECK: T tin
+# CHECK-NEXT: T _start
+# CHECK-NEXT: T pat
+
+.globl _start
+_start:
+ call pat
+ call tin
Removed: lld/trunk/test/ELF/lto/symbol-ordering-lto.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/symbol-ordering-lto.s?rev=371291&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/symbol-ordering-lto.s (original)
+++ lld/trunk/test/ELF/lto/symbol-ordering-lto.s (removed)
@@ -1,26 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
-# RUN: llvm-as %p/Inputs/symbol-ordering-lto.ll -o %t.bc
-
-# Set up the symbol file
-# RUN: echo "tin " > %t_order_lto.txt
-# RUN: echo "_start " >> %t_order_lto.txt
-# RUN: echo "pat " >> %t_order_lto.txt
-
-# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
-# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
-
-# Check that the order is tin -> _start -> pat.
-
-# CHECK: Symbol table '.symtab' contains 5 entries:
-# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
-# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
-# CHECK-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS {{.*}}.o
-# CHECK-NEXT: 2: 0000000000201008 0 NOTYPE GLOBAL DEFAULT 1 _start
-# CHECK-NEXT: 3: 0000000000201020 6 FUNC GLOBAL DEFAULT 1 pat
-# CHECK-NEXT: 4: 0000000000201000 6 FUNC GLOBAL DEFAULT 1 tin
-
-.globl _start
-_start:
- call pat
- call tin
Modified: lld/trunk/test/ELF/lto/undefined-puts.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/undefined-puts.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/undefined-puts.ll (original)
+++ lld/trunk/test/ELF/lto/undefined-puts.ll Sat Sep 7 01:20:09 2019
@@ -19,8 +19,8 @@ declare i32 @printf(i8*, ...)
; Check that puts symbol is present in the dynamic symbol table and
; there's a relocation for it.
-; CHECK: Dynamic Relocations {
-; CHECK-NEXT: 0x203018 R_X86_64_JUMP_SLOT puts 0x0
+; CHECK: Dynamic Relocations {
+; CHECK-NEXT: R_X86_64_JUMP_SLOT puts 0x0
; CHECK-NEXT: }
; CHECK: DynamicSymbols [
Modified: lld/trunk/test/ELF/lto/version-script.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/version-script.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/version-script.ll (original)
+++ lld/trunk/test/ELF/lto/version-script.ll Sat Sep 7 01:20:09 2019
@@ -3,7 +3,7 @@
; RUN: echo "VERSION_1.0{ global: foo; local: *; }; VERSION_2.0{ global: bar; local: *; };" > %t.script
; RUN: ld.lld %t.o -o %t2 -shared --version-script %t.script -save-temps
; RUN: llvm-dis < %t2.0.0.preopt.bc | FileCheck %s
-; RUN: llvm-readobj -V --dyn-syms %t2 | FileCheck --check-prefix=DSO %s
+; RUN: llvm-readobj --dyn-syms %t2 | FileCheck --check-prefix=DSO %s
target triple = "x86_64-unknown-linux-gnu"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@@ -31,7 +31,7 @@ define void @bar() {
; DSO: }
; DSO: Symbol {
; DSO: Name: foo@@VERSION_1.0
-; DSO: Value: 0x1000
+; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function
@@ -40,7 +40,7 @@ define void @bar() {
; DSO: }
; DSO: Symbol {
; DSO: Name: bar@@VERSION_2.0
-; DSO: Value: 0x1010
+; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function
Modified: lld/trunk/test/ELF/lto/version-script2.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/version-script2.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/version-script2.ll (original)
+++ lld/trunk/test/ELF/lto/version-script2.ll Sat Sep 7 01:20:09 2019
@@ -1,10 +1,13 @@
; REQUIRES: x86
+
+;; Test we parse symbol versions before LTO, otherwise we may get a symbol
+;; named "foo@@VER1", but not "foo" with the version VER1.
+
; RUN: llvm-as %s -o %t.o
; RUN: echo "VER1 {};" > %t.script
; RUN: ld.lld %t.o -o %t.so -shared --version-script %t.script
; RUN: llvm-readobj --dyn-syms %t.so | FileCheck %s
-; test that we have the correct version.
; CHECK: Name: foo@@VER1 (
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Modified: lld/trunk/test/ELF/lto/visibility.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/visibility.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/visibility.ll (original)
+++ lld/trunk/test/ELF/lto/visibility.ll Sat Sep 7 01:20:09 2019
@@ -6,7 +6,7 @@
; RUN: llvm-readobj --symbols %t.so | FileCheck %s
; CHECK: Name: g
-; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: None
@@ -16,7 +16,7 @@
; CHECK-NEXT: Section: .text
; CHECK: Name: a
-; CHECK-NEXT: Value: 0x3000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: None
Modified: lld/trunk/test/ELF/lto/weak.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/weak.ll?rev=371292&r1=371291&r2=371292&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/weak.ll (original)
+++ lld/trunk/test/ELF/lto/weak.ll Sat Sep 7 01:20:09 2019
@@ -1,4 +1,7 @@
; REQUIRES: x86
+
+;; Test weak symbols are supported in LTO.
+
; 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
@@ -11,6 +14,9 @@ define weak void @f() {
}
; CHECK: Name: f
-; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Weak
+; CHECK-NEXT: Type: Function
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: .text
More information about the llvm-commits
mailing list