mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 10:58:11 +08:00
[ELF] Improve LTO tests
Make it easy to change --save-temps filenames to follow COFF (https://reviews.llvm.org/D137217).
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
; REQUIRES: x86
|
||||
; RUN: llvm-as %s -o %t.o
|
||||
; RUN: ld.lld --lto-emit-asm -shared %t.o -o - | FileCheck %s
|
||||
; RUN: ld.lld --plugin-opt=emit-asm --plugin-opt=lto-partitions=2 -shared %t.o -o %t2.s
|
||||
; RUN: cat %t2.s %t2.s1 | FileCheck %s
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: llvm-as %s -o a.bc
|
||||
; RUN: ld.lld --lto-emit-asm -shared a.bc -o - | FileCheck %s
|
||||
; RUN: ld.lld --plugin-opt=emit-asm --plugin-opt=lto-partitions=2 -shared a.bc -o out.s
|
||||
; RUN: cat out.s out.s1 | FileCheck %s
|
||||
|
||||
; RUN: ld.lld --lto-emit-asm --save-temps -shared %t.o -o %t3.s
|
||||
; RUN: FileCheck --input-file %t3.s %s
|
||||
; RUN: llvm-dis %t3.s.0.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
|
||||
; RUN: ld.lld --lto-emit-asm --save-temps -shared a.bc -o out.s
|
||||
; RUN: FileCheck --input-file out.s %s
|
||||
; RUN: llvm-dis out.s.0.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@@ -2,18 +2,19 @@
|
||||
;; Test --lto-obj-path= for regular LTO.
|
||||
|
||||
; RUN: rm -rf %t && split-file %s %t && cd %t
|
||||
; RUN: mkdir d
|
||||
; RUN: opt 1.ll -o 1.bc
|
||||
; RUN: opt 2.ll -o 2.bc
|
||||
; RUN: opt 2.ll -o d/2.bc
|
||||
|
||||
; RUN: rm -f 4.o
|
||||
; RUN: ld.lld --lto-obj-path=4.o -shared 1.bc 2.bc -o 3
|
||||
; RUN: rm -f objpath.o
|
||||
; RUN: ld.lld --lto-obj-path=objpath.o -shared 1.bc d/2.bc -o 3
|
||||
; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM
|
||||
; RUN: llvm-objdump -d 4.o | FileCheck %s
|
||||
; RUN: ls 3* 4* | count 2
|
||||
; RUN: llvm-objdump -d objpath.o | FileCheck %s
|
||||
; RUN: ls 3* objpath* | count 2
|
||||
|
||||
; RUN: rm -f 3 4.o
|
||||
; RUN: ld.lld --thinlto-index-only=3.txt --lto-obj-path=4.o -shared 1.bc 2.bc -o 3
|
||||
; RUN: llvm-objdump -d 4.o | FileCheck %s
|
||||
; RUN: rm -f 3 objpath.o
|
||||
; RUN: ld.lld --thinlto-index-only=3.txt --lto-obj-path=objpath.o -shared 1.bc d/2.bc -o 3
|
||||
; RUN: llvm-objdump -d objpath.o | FileCheck %s
|
||||
; RUN: not ls 3
|
||||
|
||||
; NM: T f
|
||||
@@ -23,6 +24,59 @@
|
||||
; CHECK: <f>:
|
||||
; CHECK: <g>:
|
||||
|
||||
;; Test --lto-obj-path= for ThinLTO.
|
||||
; RUN: opt -module-summary 1.ll -o 1.bc
|
||||
; RUN: opt -module-summary 2.ll -o d/2.bc
|
||||
|
||||
; RUN: ld.lld --plugin-opt=obj-path=objpath.o -shared 1.bc d/2.bc -o 3
|
||||
; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM3
|
||||
; RUN: llvm-objdump -d objpath.o1 | FileCheck %s --check-prefix=CHECK1
|
||||
; RUN: llvm-objdump -d objpath.o2 | FileCheck %s --check-prefix=CHECK2
|
||||
|
||||
; NM3: T f
|
||||
; NM3-NEXT: T g
|
||||
|
||||
; CHECK1: file format elf64-x86-64
|
||||
; CHECK1-EMPTY:
|
||||
; CHECK1-NEXT: Disassembly of section .text.f:
|
||||
; CHECK1-EMPTY:
|
||||
; CHECK1-NEXT: <f>:
|
||||
; CHECK1-NEXT: retq
|
||||
; CHECK1-NOT: {{.}}
|
||||
|
||||
; CHECK2: file format elf64-x86-64
|
||||
; CHECK2-EMPTY:
|
||||
; CHECK2-NEXT: Disassembly of section .text.g:
|
||||
; CHECK2-EMPTY:
|
||||
; CHECK2-NEXT: <g>:
|
||||
; CHECK2-NEXT: retq
|
||||
; CHECK2-NOT: {{.}}
|
||||
|
||||
;; With --thinlto-index-only, --lto-obj-path= creates just one file.
|
||||
; RUN: rm -f objpath.o objpath.o1 objpath.o2
|
||||
; RUN: ld.lld --thinlto-index-only --lto-obj-path=objpath.o -shared 1.bc d/2.bc -o /dev/null
|
||||
; RUN: llvm-objdump -d objpath.o | FileCheck %s --check-prefix=EMPTY
|
||||
; RUN: not ls objpath.o1
|
||||
; RUN: not ls objpath.o2
|
||||
|
||||
;; Test --plugin-opt=obj-path=.
|
||||
; RUN: rm -f objpath.o
|
||||
; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=obj-path=objpath.o -shared 1.bc d/2.bc -o /dev/null
|
||||
; RUN: llvm-objdump -d objpath.o | FileCheck %s --check-prefix=EMPTY
|
||||
|
||||
;; Ensure lld emits empty combined module if specific obj-path.
|
||||
; RUN: mkdir obj
|
||||
; RUN: ld.lld --plugin-opt=obj-path=objpath.o -shared 1.bc d/2.bc -o obj/out --save-temps
|
||||
; RUN: ls obj/out.lto.o obj/out1.lto.o obj/out2.lto.o
|
||||
|
||||
;; Ensure lld does not emit empty combined module by default.
|
||||
; RUN: rm -fr obj && mkdir obj
|
||||
; RUN: ld.lld -shared 1.bc d/2.bc -o obj/out --save-temps
|
||||
; RUN: ls obj/out*.lto.* | count 2
|
||||
|
||||
; EMPTY: file format elf64-x86-64
|
||||
; EMPTY-NOT: {{.}}
|
||||
|
||||
;--- 1.ll
|
||||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
; REQUIRES: x86
|
||||
; RUN: llvm-as -o %t.bc %s
|
||||
; RUN: rm -f %t.lto.o %t1.lto.o
|
||||
; RUN: ld.lld --lto-partitions=2 -save-temps -o %t %t.bc \
|
||||
; RUN: -e foo --lto-O0
|
||||
; RUN: llvm-readobj --symbols --dyn-syms %t | FileCheck %s
|
||||
; RUN: llvm-nm %t.lto.o | FileCheck --check-prefix=CHECK0 %s
|
||||
; RUN: llvm-nm %t1.lto.o | FileCheck --check-prefix=CHECK1 %s
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: llvm-as -o a.bc %s
|
||||
; RUN: ld.lld --lto-partitions=2 -save-temps -o out a.bc -e foo --lto-O0
|
||||
; RUN: llvm-readobj --symbols --dyn-syms out | FileCheck %s
|
||||
; RUN: llvm-nm out.lto.o | FileCheck --check-prefix=CHECK0 %s
|
||||
; RUN: llvm-nm out1.lto.o | FileCheck --check-prefix=CHECK1 %s
|
||||
|
||||
; CHECK: Symbols [
|
||||
; CHECK-NEXT: Symbol {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
; REQUIRES: x86
|
||||
; RUN: llvm-as -o %t.bc %s
|
||||
; RUN: rm -f %t.lto.o %t1.lto.o
|
||||
; RUN: ld.lld --lto-partitions=2 -save-temps -o %t %t.bc -shared
|
||||
; RUN: llvm-nm %t.lto.o | FileCheck --check-prefix=CHECK0 %s
|
||||
; RUN: llvm-nm %t1.lto.o | FileCheck --check-prefix=CHECK1 %s
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: llvm-as -o a.bc %s
|
||||
; RUN: ld.lld --lto-partitions=2 -save-temps -o out a.bc -shared
|
||||
; RUN: llvm-nm out.lto.o | FileCheck --check-prefix=CHECK0 %s
|
||||
; RUN: llvm-nm out1.lto.o | FileCheck --check-prefix=CHECK1 %s
|
||||
|
||||
; RUN: not ld.lld --lto-partitions=0 %t.bc -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s
|
||||
; RUN: not ld.lld --lto-partitions=0 a.bc -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s
|
||||
; INVALID: --lto-partitions: number of threads must be > 0
|
||||
|
||||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
; REQUIRES: x86
|
||||
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: opt -module-summary %s -o 1.bc
|
||||
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.bc
|
||||
|
||||
; RUN: ld.lld --plugin-opt=obj-path=4.o -shared 1.bc 2.bc -o 3
|
||||
; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM3
|
||||
; RUN: llvm-objdump -d 4.o1 | FileCheck %s --check-prefix=CHECK1
|
||||
; RUN: llvm-objdump -d 4.o2 | FileCheck %s --check-prefix=CHECK2
|
||||
|
||||
; NM3: T f
|
||||
; NM3-NEXT: T g
|
||||
|
||||
; CHECK1: file format elf64-x86-64
|
||||
; CHECK1-EMPTY:
|
||||
; CHECK1-NEXT: Disassembly of section .text.f:
|
||||
; CHECK1-EMPTY:
|
||||
; CHECK1-NEXT: <f>:
|
||||
; CHECK1-NEXT: retq
|
||||
; CHECK1-NOT: {{.}}
|
||||
|
||||
; CHECK2: file format elf64-x86-64
|
||||
; CHECK2-EMPTY:
|
||||
; CHECK2-NEXT: Disassembly of section .text.g:
|
||||
; CHECK2-EMPTY:
|
||||
; CHECK2-NEXT: <g>:
|
||||
; CHECK2-NEXT: retq
|
||||
; CHECK2-NOT: {{.}}
|
||||
|
||||
;; With --thinlto-index-only, --lto-obj-path= creates just one file.
|
||||
; RUN: rm -f 4.o 4.o1 4.o2
|
||||
; RUN: ld.lld --thinlto-index-only --lto-obj-path=4.o -shared 1.bc 2.bc -o /dev/null
|
||||
; RUN: llvm-objdump -d 4.o | FileCheck %s --check-prefix=EMPTY
|
||||
; RUN: not ls 4.o1
|
||||
; RUN: not ls 4.o2
|
||||
|
||||
;; Test --plugin-opt=obj-path=.
|
||||
; RUN: rm -f 4.o
|
||||
; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=obj-path=4.o -shared 1.bc 2.bc -o /dev/null
|
||||
; RUN: llvm-objdump -d 4.o | FileCheck %s --check-prefix=EMPTY
|
||||
|
||||
;; Ensure lld emits empty combined module if specific obj-path.
|
||||
; RUN: rm -fr objpath && mkdir objpath
|
||||
; RUN: ld.lld --plugin-opt=obj-path=4.o -shared 1.bc 2.bc -o objpath/a.out --save-temps
|
||||
; RUN: ls objpath/a.out*.lto.* | count 3
|
||||
|
||||
;; Ensure lld does not emit empty combined module in default.
|
||||
; RUN: rm -fr objpath && mkdir objpath
|
||||
; RUN: ld.lld -shared 1.bc 2.bc -o objpath/a.out --save-temps
|
||||
; RUN: ls objpath/a.out*.lto.* | count 2
|
||||
|
||||
; EMPTY: file format elf64-x86-64
|
||||
; EMPTY-NOT: {{.}}
|
||||
|
||||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
declare void @g(...)
|
||||
|
||||
define void @f() {
|
||||
entry:
|
||||
call void (...) @g()
|
||||
ret void
|
||||
}
|
||||
@@ -1,68 +1,69 @@
|
||||
; REQUIRES: x86
|
||||
|
||||
; Basic ThinLTO tests.
|
||||
; RUN: opt -module-summary %s -o %t1.o
|
||||
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: mkdir d e
|
||||
; RUN: opt -module-summary %s -o 1.o
|
||||
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o d/2.o
|
||||
|
||||
; First force single-threaded mode
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
; Next force multi-threaded mode
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=2 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=2 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
;; --plugin-opt=jobs= is an alias.
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --plugin-opt=jobs=2 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --plugin-opt=jobs=2 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
;; --thinlto-jobs= defaults to --threads=.
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --threads=2 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --threads=2 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
;; --thinlto-jobs= overrides --threads=.
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --threads=1 --plugin-opt=jobs=2 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --threads=1 --plugin-opt=jobs=2 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
; Test with all threads, on all cores, on all CPU sockets
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=all -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=all -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
; Test with many more threads than the system has
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=100 -shared %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: ld.lld -save-temps --thinlto-jobs=100 -shared 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
; Test with a bad value
|
||||
; RUN: rm -f %t31.lto.o %t32.lto.o
|
||||
; RUN: not ld.lld -save-temps --thinlto-jobs=foo -shared %t1.o %t2.o -o %t3 2>&1 | FileCheck %s --check-prefix=BAD-JOBS
|
||||
; RUN: rm -f e/out1.lto.o e/out2.lto.o
|
||||
; RUN: not ld.lld -save-temps --thinlto-jobs=foo -shared 1.o d/2.o -o e/out 2>&1 | FileCheck %s --check-prefix=BAD-JOBS
|
||||
; BAD-JOBS: error: --thinlto-jobs: invalid job count: foo
|
||||
|
||||
; Then check without --thinlto-jobs (which currently defaults to heavyweight_hardware_concurrency, meanning one thread per hardware core -- not SMT)
|
||||
; RUN: ld.lld -shared -save-temps %t1.o %t2.o -o %t3
|
||||
; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
|
||||
; RUN: ld.lld -shared -save-temps 1.o d/2.o -o e/out
|
||||
; RUN: llvm-nm e/out1.lto.o | FileCheck %s --check-prefix=NM1
|
||||
; RUN: llvm-nm e/out2.lto.o | FileCheck %s --check-prefix=NM2
|
||||
|
||||
; Check that -save-temps is usable with thin archives
|
||||
; RUN: rm -fr %t.dir
|
||||
; RUN: mkdir -p %t.dir
|
||||
; RUN: cp %t2.o %t.dir/t.o
|
||||
; RUN: llvm-ar rcsT %t.dir/t.a %t.dir/t.o
|
||||
; RUN: ld.lld -save-temps %t1.o %t.dir/t.a -o %t.null
|
||||
; RUN: ls %t.dir/t.a*.0.preopt.bc
|
||||
; RUN: mkdir dir
|
||||
; RUN: cp d/2.o dir/t.o
|
||||
; RUN: llvm-ar rcsT dir/t.a dir/t.o
|
||||
; RUN: ld.lld -save-temps 1.o dir/t.a -o %t.null
|
||||
; RUN: ls dir/t.a*.0.preopt.bc
|
||||
|
||||
; NM1: T f
|
||||
; NM2: T g
|
||||
|
||||
Reference in New Issue
Block a user