Skip to content

Commit fa6da90

Browse files
committed
[lld][ELF][test] Add additional LTO testing
The additional testing is testing we previously had in a downstream test suite. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D87824
1 parent 98aed8a commit fa6da90

File tree

4 files changed

+150
-20
lines changed

4 files changed

+150
-20
lines changed

Diff for: lld/test/ELF/lto/archive-mixed.test

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
; REQUIRES: x86
2+
;; Show that whether an object is a bitcode file or regular ELF object does not
3+
;; make any difference to which file is selected from an archive.
4+
5+
; RUN: rm -rf %t.dir
6+
; RUN: split-file %s %t.dir
7+
; RUN: cd %t.dir
8+
9+
; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux ref.s -o ref.o
10+
; RUN: llvm-as a.ll -o a.bc
11+
; RUN: llvm-as b.ll -o b.bc
12+
; RUN: llc -filetype=obj a.ll -o a.o
13+
; RUN: llc -filetype=obj b.ll -o b.o
14+
15+
; RUN: llvm-ar rc a.bc.b.bc.a a.bc b.bc
16+
; RUN: llvm-ar rc a.bc.b.o.a a.bc b.o
17+
; RUN: llvm-ar rc a.o.b.bc.a a.o b.bc
18+
; RUN: llvm-ar rc a.o.b.o.a a.o b.o
19+
; RUN: llvm-ar rc other.bc.a a.bc
20+
; RUN: llvm-ar rc other.o.a a.o
21+
22+
; RUN: ld.lld -o /dev/null --trace ref.o a.bc.b.bc.a other.bc.a | \
23+
; RUN: FileCheck %s --implicit-check-not={{.}}
24+
; RUN: ld.lld -o /dev/null --trace ref.o a.bc.b.bc.a other.o.a | \
25+
; RUN: FileCheck %s --implicit-check-not={{.}}
26+
; RUN: ld.lld -o /dev/null --trace ref.o a.bc.b.o.a other.bc.a | \
27+
; RUN: FileCheck %s --implicit-check-not={{.}}
28+
; RUN: ld.lld -o /dev/null --trace ref.o a.bc.b.o.a other.o.a | \
29+
; RUN: FileCheck %s --implicit-check-not={{.}}
30+
; RUN: ld.lld -o /dev/null --trace ref.o a.o.b.bc.a other.bc.a | \
31+
; RUN: FileCheck %s --implicit-check-not={{.}}
32+
; RUN: ld.lld -o /dev/null --trace ref.o a.o.b.bc.a other.o.a | \
33+
; RUN: FileCheck %s --implicit-check-not={{.}}
34+
; RUN: ld.lld -o /dev/null --trace ref.o a.o.b.o.a other.bc.a | \
35+
; RUN: FileCheck %s --implicit-check-not={{.}}
36+
;; Not an LTO test case, but here for completeness.
37+
; RUN: ld.lld -o /dev/null --trace ref.o a.o.b.o.a other.o.a | \
38+
; RUN: FileCheck %s --implicit-check-not={{.}}
39+
40+
; CHECK: ref.o
41+
; CHECK-NEXT: a.{{.*}}.b.{{.*}}.a(b.{{.*}})
42+
; CHECK-NEXT: a.{{.*}}.b.{{.*}}.a(a.{{.*}})
43+
44+
;--- a.ll
45+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
46+
target triple = "x86_64-unknown-linux"
47+
define void @bar() {
48+
ret void
49+
}
50+
51+
;--- b.ll
52+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
53+
target triple = "x86_64-unknown-linux"
54+
define void @foo() {
55+
call void @bar()
56+
ret void
57+
}
58+
declare void @bar()
59+
60+
;--- ref.s
61+
.global _start
62+
_start:
63+
call foo

Diff for: lld/test/ELF/lto/internalize-basic.ll

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ target triple = "x86_64-unknown-linux-gnu"
77
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
88

99
define void @_start() {
10+
call void @bar()
11+
ret void
12+
}
13+
14+
define void @bar() {
1015
ret void
1116
}
1217

@@ -17,5 +22,6 @@ define hidden void @foo() {
1722
; Check that _start is not internalized.
1823
; CHECK: define dso_local void @_start()
1924

20-
; Check that foo function is correctly internalized.
25+
; Check that the foo and bar functions are correctly internalized.
26+
; CHECK: define internal void @bar()
2127
; CHECK: define internal void @foo()

Diff for: lld/test/ELF/lto/undef-mixed2.test

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# REQUIRES: x86
2+
## Show that a symbol referenced from an object and defined in bitcode is
3+
## not internalized and is emitted in the output.
4+
5+
# RUN: rm -rf %t.dir
6+
# RUN: split-file %s %t.dir
7+
# RUN: llvm-mc %t.dir/obj.s -o %t.o -filetype=obj -triple=x86_64-pc-linux
8+
# RUN: llvm-as %t.dir/bc.ll -o %t2.o
9+
# RUN: ld.lld %t2.o %t.o -o %t.so -shared
10+
# RUN: llvm-readobj --symbols %t.so | FileCheck %s
11+
12+
# CHECK: Name: foo
13+
# CHECK-NEXT: Value:
14+
# CHECK-NEXT: Size:
15+
# CHECK-NEXT: Binding: Local
16+
# CHECK-NEXT: Type: Function
17+
# CHECK-NEXT: Other [
18+
# CHECK-NEXT: STV_HIDDEN
19+
# CHECK-NEXT: ]
20+
# CHECK-NEXT: Section: .text
21+
22+
#--- obj.s
23+
.globl bar
24+
bar:
25+
call foo
26+
27+
#--- bc.ll
28+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
29+
target triple = "x86_64-unknown-linux-gnu"
30+
31+
define hidden void @foo() {
32+
ret void
33+
}

Diff for: lld/test/ELF/lto/wrap-2.ll

+47-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
11
; REQUIRES: x86
2-
; LTO
3-
; RUN: llvm-as %s -o %t.o
4-
; RUN: llvm-as %S/Inputs/wrap-bar.ll -o %t1.o
5-
; RUN: ld.lld %t.o %t1.o -shared -o %t.so -wrap=bar
6-
; RUN: llvm-objdump -d %t.so | FileCheck %s
7-
; RUN: llvm-readobj --symbols %t.so | FileCheck -check-prefix=BIND %s
8-
9-
; ThinLTO
10-
; RUN: opt -module-summary %s -o %t.o
11-
; RUN: opt -module-summary %S/Inputs/wrap-bar.ll -o %t1.o
12-
; RUN: ld.lld %t.o %t1.o -shared -o %t.so -wrap=bar
13-
; RUN: llvm-objdump -d %t.so | FileCheck %s
14-
; RUN: llvm-readobj --symbols %t.so | FileCheck -check-prefix=BIND %s
15-
16-
; Make sure that calls in foo() are not eliminated and that bar is
17-
; routed to __wrap_bar and __real_bar is routed to bar.
2+
;; This test verifies that --wrap works correctly for inter-module references to
3+
;; the wrapped symbol, when LTO or ThinLTO is involved. It checks for various
4+
;; combinations of bitcode and regular objects.
5+
6+
;; LTO + LTO
7+
; RUN: llvm-as %s -o %t1.bc
8+
; RUN: llvm-as %S/Inputs/wrap-bar.ll -o %t2.bc
9+
; RUN: ld.lld %t1.bc %t2.bc -shared -o %t.bc-bc.so -wrap=bar
10+
; RUN: llvm-objdump -d %t.bc-bc.so | FileCheck %s --check-prefixes=CHECK,JMP
11+
; RUN: llvm-readobj --symbols %t.bc-bc.so | FileCheck --check-prefix=BIND %s
12+
13+
;; LTO + Object
14+
; RUN: llc %S/Inputs/wrap-bar.ll -o %t2.o --filetype=obj
15+
; RUN: ld.lld %t1.bc %t2.o -shared -o %t.bc-o.so -wrap=bar
16+
; RUN: llvm-objdump -d %t.bc-o.so | FileCheck %s --check-prefixes=CHECK,JMP
17+
; RUN: llvm-readobj --symbols %t.bc-o.so | FileCheck --check-prefix=BIND %s
18+
19+
;; Object + LTO
20+
; RUN: llc %s -o %t1.o --filetype=obj
21+
; RUN: ld.lld %t1.o %t2.bc -shared -o %t.o-bc.so -wrap=bar
22+
; RUN: llvm-objdump -d %t.o-bc.so | FileCheck %s --check-prefixes=CHECK,CALL
23+
; RUN: llvm-readobj --symbols %t.o-bc.so | FileCheck --check-prefix=BIND %s
24+
25+
;; ThinLTO + ThinLTO
26+
; RUN: opt -module-summary %s -o %t1.thin
27+
; RUN: opt -module-summary %S/Inputs/wrap-bar.ll -o %t2.thin
28+
; RUN: ld.lld %t1.thin %t2.thin -shared -o %t.thin-thin.so -wrap=bar
29+
; RUN: llvm-objdump -d %t.thin-thin.so | FileCheck %s --check-prefixes=CHECK,JMP
30+
; RUN: llvm-readobj --symbols %t.thin-thin.so | FileCheck --check-prefix=BIND %s
31+
32+
;; ThinLTO + Object
33+
; RUN: ld.lld %t1.thin %t2.o -shared -o %t.thin-o.so -wrap=bar
34+
; RUN: llvm-objdump -d %t.thin-o.so | FileCheck %s --check-prefixes=CHECK,JMP
35+
; RUN: llvm-readobj --symbols %t.thin-o.so | FileCheck --check-prefix=BIND %s
36+
37+
;; Object + ThinLTO
38+
; RUN: ld.lld %t1.o %t2.thin -shared -o %t.o-thin.so -wrap=bar
39+
; RUN: llvm-objdump -d %t.o-thin.so | FileCheck %s --check-prefixes=CHECK,CALL
40+
; RUN: llvm-readobj --symbols %t.o-thin.so | FileCheck --check-prefix=BIND %s
41+
42+
;; Make sure that calls in foo() are not eliminated and that bar is
43+
;; routed to __wrap_bar and __real_bar is routed to bar.
1844

1945
; CHECK: <foo>:
2046
; CHECK-NEXT: pushq %rax
2147
; CHECK-NEXT: callq{{.*}}<__wrap_bar>
22-
; CHECK-NEXT: popq %rax
23-
; CHECK-NEXT: jmp{{.*}}<bar>
48+
; JMP-NEXT: popq %rax
49+
; JMP-NEXT: jmp{{.*}}<bar>
50+
; CALL-NEXT: callq{{.*}}<bar>
51+
; CALL-NEXT: popq %rax
2452

25-
; Check that bar and __wrap_bar retain their original binding.
53+
;; Check that bar and __wrap_bar retain their original binding.
2654
; BIND: Name: bar
2755
; BIND-NEXT: Value:
2856
; BIND-NEXT: Size:

0 commit comments

Comments
 (0)