From: Fangrui Song Date: Sat, 7 Sep 2019 08:20:09 +0000 (+0000) Subject: [ELF][test] Improve LTO tests X-Git-Tag: llvmorg-11-init~9770 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89f7859641f4ae799d869d077cb82e574b6238d6;p=platform%2Fupstream%2Fllvm.git [ELF][test] Improve LTO tests Add file-level comments Delete insignificant addresses to make them more tolerant to layout changes Simplify test output llvm-svn: 371292 --- diff --git a/lld/test/ELF/lto/comdat2.ll b/lld/test/ELF/lto/comdat2.ll index 3a23198..8cd4559 100644 --- a/lld/test/ELF/lto/comdat2.ll +++ b/lld/test/ELF/lto/comdat2.ll @@ -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 diff --git a/lld/test/ELF/lto/data-ordering-lto.s b/lld/test/ELF/lto/data-ordering-lto.s deleted file mode 100644 index f3cd52b..0000000 --- a/lld/test/ELF/lto/data-ordering-lto.s +++ /dev/null @@ -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 diff --git a/lld/test/ELF/lto/dynamic-list.ll b/lld/test/ELF/lto/dynamic-list.ll index 05a5f39..5504ad0 100644 --- a/lld/test/ELF/lto/dynamic-list.ll +++ b/lld/test/ELF/lto/dynamic-list.ll @@ -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 diff --git a/lld/test/ELF/lto/linker-script-symbols-ipo.ll b/lld/test/ELF/lto/linker-script-symbols-ipo.ll index 4cc95c6ca..ba12bd5 100644 --- a/lld/test/ELF/lto/linker-script-symbols-ipo.ll +++ b/lld/test/ELF/lto/linker-script-symbols-ipo.ll @@ -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 +; NOIPO-NEXT: jmp -21 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/lld/test/ELF/lto/obj-path.ll b/lld/test/ELF/lto/obj-path.ll index 808e17b..0f720d7 100644 --- a/lld/test/ELF/lto/obj-path.ll +++ b/lld/test/ELF/lto/obj-path.ll @@ -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 diff --git a/lld/test/ELF/lto/parallel-internalize.ll b/lld/test/ELF/lto/parallel-internalize.ll index 907ba47..3b1b106 100644 --- a/lld/test/ELF/lto/parallel-internalize.ll +++ b/lld/test/ELF/lto/parallel-internalize.ll @@ -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) diff --git a/lld/test/ELF/lto/shlib-undefined.ll b/lld/test/ELF/lto/shlib-undefined.ll index 01fe915..b2f0d4a 100644 --- a/lld/test/ELF/lto/shlib-undefined.ll +++ b/lld/test/ELF/lto/shlib-undefined.ll @@ -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 diff --git a/lld/test/ELF/lto/symbol-ordering-data.s b/lld/test/ELF/lto/symbol-ordering-data.s new file mode 100644 index 0000000..4319d2b --- /dev/null +++ b/lld/test/ELF/lto/symbol-ordering-data.s @@ -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 diff --git a/lld/test/ELF/lto/symbol-ordering-function.s b/lld/test/ELF/lto/symbol-ordering-function.s new file mode 100644 index 0000000..b2e8a4d --- /dev/null +++ b/lld/test/ELF/lto/symbol-ordering-function.s @@ -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 diff --git a/lld/test/ELF/lto/symbol-ordering-lto.s b/lld/test/ELF/lto/symbol-ordering-lto.s deleted file mode 100644 index 6a35c60..0000000 --- a/lld/test/ELF/lto/symbol-ordering-lto.s +++ /dev/null @@ -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 diff --git a/lld/test/ELF/lto/undefined-puts.ll b/lld/test/ELF/lto/undefined-puts.ll index 777ca56..8f98789 100644 --- a/lld/test/ELF/lto/undefined-puts.ll +++ b/lld/test/ELF/lto/undefined-puts.ll @@ -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 [ diff --git a/lld/test/ELF/lto/version-script.ll b/lld/test/ELF/lto/version-script.ll index f12d7b6..ae6441b 100644 --- a/lld/test/ELF/lto/version-script.ll +++ b/lld/test/ELF/lto/version-script.ll @@ -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 diff --git a/lld/test/ELF/lto/version-script2.ll b/lld/test/ELF/lto/version-script2.ll index 899a42b..29fa3f9 100644 --- a/lld/test/ELF/lto/version-script2.ll +++ b/lld/test/ELF/lto/version-script2.ll @@ -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" diff --git a/lld/test/ELF/lto/visibility.ll b/lld/test/ELF/lto/visibility.ll index fdf579a..11518ab 100644 --- a/lld/test/ELF/lto/visibility.ll +++ b/lld/test/ELF/lto/visibility.ll @@ -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 diff --git a/lld/test/ELF/lto/weak.ll b/lld/test/ELF/lto/weak.ll index f716e33..d683c34 100644 --- a/lld/test/ELF/lto/weak.ll +++ b/lld/test/ELF/lto/weak.ll @@ -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