[lld] 4512dda - [ELF][test] Clean up thinlto*

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 16:19:21 PDT 2022


Author: Fangrui Song
Date: 2022-06-22T16:19:17-07:00
New Revision: 4512dda6af1bb22cf836c9e8aa0f054d2b52ec17

URL: https://github.com/llvm/llvm-project/commit/4512dda6af1bb22cf836c9e8aa0f054d2b52ec17
DIFF: https://github.com/llvm/llvm-project/commit/4512dda6af1bb22cf836c9e8aa0f054d2b52ec17.diff

LOG: [ELF][test] Clean up thinlto*

Added: 
    

Modified: 
    lld/test/ELF/lto/thinlto-index-file.ll
    lld/test/ELF/lto/thinlto-index-only.ll
    lld/test/ELF/lto/thinlto-object-suffix-replace.ll

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/lto/thinlto-index-file.ll b/lld/test/ELF/lto/thinlto-index-file.ll
index 4135c1ad4bf3..00feef725844 100644
--- a/lld/test/ELF/lto/thinlto-index-file.ll
+++ b/lld/test/ELF/lto/thinlto-index-file.ll
@@ -1,20 +1,19 @@
 ; REQUIRES: x86
+; RUN: rm -rf %t && mkdir %t && cd %t
+; RUN: opt -module-summary %s -o 1.o
+; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.o
+; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o
 
-; Basic ThinLTO tests.
-; RUN: opt -module-summary %s -o %t1.o
-; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
-; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o %t3.o
+;; Ensure lld writes linked files to linked objects file
+; RUN: ld.lld --plugin-opt=thinlto-index-only=1.txt -shared 1.o 2.o 3.o -o /dev/null
+; RUN: FileCheck %s < 1.txt
+; CHECK: 1.o
+; CHECK: 2.o
+; CHECK: 3.o
 
-; Ensure lld writes linked files to linked objects file
-; RUN: ld.lld --plugin-opt=thinlto-index-only=%t.idx -shared %t1.o %t2.o %t3.o -o /dev/null
-; RUN: FileCheck %s < %t.idx
-; CHECK: {{.*}}thinlto-index-file.ll.tmp1.o
-; CHECK: {{.*}}thinlto-index-file.ll.tmp2.o
-; CHECK: {{.*}}thinlto-index-file.ll.tmp3.o
-
-; Check that this also works without the --plugin-opt= prefix.
-; RUN: ld.lld --thinlto-index-only=%t.idx -shared %t1.o %t2.o %t3.o -o /dev/null
-; RUN: FileCheck %s < %t.idx
+;; Check that this also works without the --plugin-opt= prefix.
+; RUN: ld.lld --thinlto-index-only=2.txt -shared 1.o 2.o 3.o -o /dev/null
+; RUN: 
diff  1.txt 2.txt
 
 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"

diff  --git a/lld/test/ELF/lto/thinlto-index-only.ll b/lld/test/ELF/lto/thinlto-index-only.ll
index 4c3c7e1b1917..7385d6680826 100644
--- a/lld/test/ELF/lto/thinlto-index-only.ll
+++ b/lld/test/ELF/lto/thinlto-index-only.ll
@@ -1,56 +1,54 @@
 ; REQUIRES: x86
+; RUN: rm -rf %t && mkdir %t && cd %t
 
-; First ensure that the ThinLTO handling in lld handles
-; bitcode without summary sections gracefully and generates index file.
-; RUN: llvm-as %s -o %t1.o
-; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o
-; RUN: rm -f %t3
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t2.o -o %t3
-; RUN: ls %t2.o.thinlto.bc
-; RUN: not test -e %t3
-; RUN: ld.lld -shared %t1.o %t2.o -o %t3
-; RUN: llvm-nm %t3 | FileCheck %s --check-prefix=NM
+;; First ensure that the ThinLTO handling in lld handles
+;; bitcode without summary sections gracefully and generates index file.
+; RUN: llvm-as %s -o 1.o
+; RUN: llvm-as %p/Inputs/thinlto.ll -o 2.o
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 3
+; RUN: ls 2.o.thinlto.bc
+; RUN: not test -e 3
+; RUN: ld.lld -shared 1.o 2.o -o 3
+; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM
 
-; Basic ThinLTO tests.
-; RUN: opt -module-summary %s -o %t1.o
-; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
-; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o %t3.o
+;; Basic ThinLTO tests.
+; RUN: opt -module-summary %s -o 1.o
+; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.o
+; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o
 
-; Ensure lld generates an index and not a binary if requested.
-; RUN: rm -f %t4
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t2.o -o %t4
-; RUN: llvm-bcanalyzer -dump %t1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
-; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
-; RUN: not test -e %t4
+;; Ensure lld generates an index and not a binary if requested.
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 4
+; RUN: llvm-bcanalyzer -dump 1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
+; RUN: llvm-bcanalyzer -dump 2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
+; RUN: not test -e 4
 
-; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib
-; RUN: rm -f %t2.o.thinlto.bc %t4
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t3.o --start-lib %t2.o --end-lib -o %t4
-; RUN: llvm-dis < %t2.o.thinlto.bc | grep -q '\^0 = module:'
-; RUN: not test -e %t4
+;; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib
+; RUN: rm -f 2.o.thinlto.bc 4
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 3.o --start-lib 2.o --end-lib -o 4
+; RUN: llvm-dis < 2.o.thinlto.bc | grep -q '\^0 = module:'
+; RUN: not test -e 4
 
-; Test that LLD generates an empty index even for lazy object file that is not added to link.
-; Test LLD generates empty imports file either because of thinlto-emit-imports-files option.
-; RUN: rm -f %t1.o.thinlto.bc
-; RUN: rm -f %t1.o.imports
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t2.o --start-lib %t1.o --end-lib \
-; RUN: --plugin-opt=thinlto-emit-imports-files -o %t3
-; RUN: ls %t1.o.thinlto.bc
-; RUN: ls %t1.o.imports
+;; Test that LLD generates an empty index even for lazy object file that is not added to link.
+;; Test LLD generates empty imports file either because of thinlto-emit-imports-files option.
+; RUN: rm -f 1.o.thinlto.bc 1.o.imports
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 2.o --start-lib 1.o --end-lib \
+; RUN: --plugin-opt=thinlto-emit-imports-files -o 3
+; RUN: ls 1.o.thinlto.bc
+; RUN: ls 1.o.imports
 
-; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy.
-; RUN: rm -f %t1.o.thinlto.bc
-; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu /dev/null -o %tdummy.o
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %tdummy.o --start-lib %t1.o --end-lib -o /dev/null
-; RUN: ls %t1.o.thinlto.bc
+;; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy.
+; RUN: rm -f 1.o.thinlto.bc
+; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu /dev/null -o dummy.o
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared dummy.o --start-lib 1.o --end-lib -o /dev/null
+; RUN: ls 1.o.thinlto.bc
 
 ; NM: T f
 
-; The backend index for this module contains summaries from itself and
-; Inputs/thinlto.ll, as it imports from the latter.
+;; The backend index for this module contains summaries from itself and
+;; Inputs/thinlto.ll, as it imports from the latter.
 ; BACKEND1: <MODULE_STRTAB_BLOCK
-; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
-; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
+; BACKEND1-NEXT: <ENTRY {{.*}} record string = '1.o'
+; BACKEND1-NEXT: <ENTRY {{.*}} record string = '2.o'
 ; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
 ; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK
 ; BACKEND1: <VERSION
@@ -61,10 +59,10 @@
 ; BACKEND1: <COMBINED
 ; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK
 
-; The backend index for Input/thinlto.ll contains summaries from itself only,
-; as it does not import anything.
+;; The backend index for Input/thinlto.ll contains summaries from itself only,
+;; as it does not import anything.
 ; BACKEND2: <MODULE_STRTAB_BLOCK
-; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp2.o'
+; BACKEND2-NEXT: <ENTRY {{.*}} record string = '2.o'
 ; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
 ; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
 ; BACKEND2-NEXT: <VERSION

diff  --git a/lld/test/ELF/lto/thinlto-object-suffix-replace.ll b/lld/test/ELF/lto/thinlto-object-suffix-replace.ll
index d22d79d34d58..2ae17ce5698f 100644
--- a/lld/test/ELF/lto/thinlto-object-suffix-replace.ll
+++ b/lld/test/ELF/lto/thinlto-object-suffix-replace.ll
@@ -1,45 +1,41 @@
 ; REQUIRES: x86
+;; Test to make sure the thinlto-object-suffix-replace option is handled
+;; correctly.
+; RUN: rm -rf %t && mkdir %t && cd %t
 
-; Test to make sure the thinlto-object-suffix-replace option is handled
-; correctly.
-
-; Generate bitcode file with summary, as well as a minimized bitcode without
+;; Generate bitcode file with summary, as well as a minimized bitcode without
 ; the debug metadata for the thin link.
-; RUN: opt --thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.o
-
-; First perform the thin link on the normal bitcode file, and save the
-; resulting index.
-; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o -o %t3
-; RUN: cp %t1.o.thinlto.bc %t1.o.thinlto.bc.orig
-
-; Next perform the thin link on the minimized bitcode file, and compare dump
-; of the resulting index to the above dump to ensure they are identical.
-; RUN: rm -f %t1.o.thinlto.bc
-; Make sure it isn't inadvertently using the regular bitcode file.
-; RUN: rm -f %t1.o
-; RUN: ld.lld --plugin-opt=thinlto-index-only \
-; RUN: --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
-; RUN: -shared %t1.thinlink.bc -o %t3
-; RUN: 
diff  %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
-; Also check that this works without the --plugin-opt= prefix.
-; RUN: ld.lld --thinlto-index-only \
-; RUN: --thinlto-object-suffix-replace=".thinlink.bc;.o" \
-; RUN: -shared %t1.thinlink.bc -o %t3
-; RUN: 
diff  %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
-
-; Ensure lld generates error if object suffix replace option does not have 'old;new' format
-; RUN: rm -f %t1.o.thinlto.bc
-; RUN: not ld.lld --plugin-opt=thinlto-index-only \
-; RUN: --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared %t1.thinlink.bc \
-; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR1
+; RUN: opt --thinlto-bc %s -thin-link-bitcode-file=1.thinlink.bc -o 1.o
+
+;; First perform the thin link on the normal bitcode file, and save the
+;; resulting index.
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o -o 3
+; RUN: cp 1.o.thinlto.bc 1.o.thinlto.bc.orig
+
+;; Next perform the thin link on the minimized bitcode file, and compare dump
+;; of the resulting index to the above dump to ensure they are identical.
+; RUN: rm -f 1.o.thinlto.bc
+;; Make sure it isn't inadvertently using the regular bitcode file.
+; RUN: rm -f 1.o
+; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
+; RUN:   -shared 1.thinlink.bc -o 3
+; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
+;; Also check that this works without the --plugin-opt= prefix.
+; RUN: ld.lld --thinlto-index-only --thinlto-object-suffix-replace=".thinlink.bc;.o" \
+; RUN:   -shared 1.thinlink.bc -o 3
+; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
+
+;; Ensure lld generates error if object suffix replace option does not have 'old;new' format
+; RUN: rm -f 1.o.thinlto.bc
+; RUN: not ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared 1.thinlink.bc \
+; RUN:   -o 3 2>&1 | FileCheck %s --check-prefix=ERR1
 ; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
 
-; If filename does not end with old suffix, no suffix change should occur,
-; so ".thinlto.bc" will simply be appended to the input file name.
-; RUN: rm -f %t1.thinlink.bc.thinlto.bc
-; RUN: ld.lld --plugin-opt=thinlto-index-only \
-; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc -o /dev/null
-; RUN: ls %t1.thinlink.bc.thinlto.bc
+;; If filename does not end with old suffix, no suffix change should occur,
+;; so ".thinlto.bc" will simply be appended to the input file name.
+; RUN: rm -f 1.thinlink.bc.thinlto.bc
+; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared 1.thinlink.bc -o /dev/null
+; RUN: ls 1.thinlink.bc.thinlto.bc
 
 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"


        


More information about the llvm-commits mailing list