diff options
author | Fangrui Song <maskray@google.com> | 2020-02-07 21:42:14 -0800 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-02-07 22:37:11 -0800 |
commit | 70e0935256fc173fbc57c7333727ab222af476eb (patch) | |
tree | 645cf4bf0785ae419f70675c1faedd8a0704222c | |
parent | 8d4fe864c4bdc53b3e6a2df43112520cb646afcf (diff) | |
download | llvm-70e0935256fc173fbc57c7333727ab222af476eb.zip llvm-70e0935256fc173fbc57c7333727ab222af476eb.tar.gz llvm-70e0935256fc173fbc57c7333727ab222af476eb.tar.bz2 |
[Driver][test] Refactor LLVMgold tests
LLVMgold.so tests are duplicated in several places. Deduplicate them.
Move the tests to lto.c and lto.cu
Specify -fuse-ld=bfd or -fuse-ld=gold.
In a future change, if -fuse-ld=lld or CLANG_DEFAULT_LINKER=lld without -fuse-ld=, we will remove -plugin /path/to/LLVMgold.so
-rw-r--r-- | clang/test/Driver/freebsd.c | 4 | ||||
-rw-r--r-- | clang/test/Driver/gold-lto.c | 28 | ||||
-rw-r--r-- | clang/test/Driver/lto-plugin-darwin.c | 6 | ||||
-rw-r--r-- | clang/test/Driver/lto-plugin-linux.c | 6 | ||||
-rw-r--r-- | clang/test/Driver/lto-plugin-windows.c | 6 | ||||
-rw-r--r-- | clang/test/Driver/lto.c | 29 | ||||
-rw-r--r-- | clang/test/Driver/lto.cu | 25 | ||||
-rw-r--r-- | clang/test/Driver/thinlto.c | 22 | ||||
-rw-r--r-- | clang/test/Driver/thinlto.cu | 25 |
9 files changed, 21 insertions, 130 deletions
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c index dc209704..5eb00ce 100644 --- a/clang/test/Driver/freebsd.c +++ b/clang/test/Driver/freebsd.c @@ -161,10 +161,6 @@ // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp" // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs" -// RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-LTO %s -// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}} - // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-SPARC-PIE %s // CHECK-SPARC-PIE: as{{.*}}" "-KPIC diff --git a/clang/test/Driver/gold-lto.c b/clang/test/Driver/gold-lto.c deleted file mode 100644 index d16961e..0000000 --- a/clang/test/Driver/gold-lto.c +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: touch %t.o -// -// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \ -// RUN: -Wl,-plugin-opt=foo -O3 \ -// RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC -// CHECK-X86-64-BASIC: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-X86-64-BASIC: "-plugin-opt=O3" -// CHECK-X86-64-BASIC: "-plugin-opt=foo" -// -// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \ -// RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \ -// RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7 -// CHECK-X86-64-COREI7: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7" -// CHECK-X86-64-COREI7: "-plugin-opt=O3" -// CHECK-X86-64-COREI7: "-plugin-opt=foo" -// -// RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \ -// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \ -// RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A -// CHECK-ARM-V7A: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-ARM-V7A: "-plugin-opt=mcpu=generic" -// CHECK-ARM-V7A: "-plugin-opt=O0" -// CHECK-ARM-V7A: "-plugin-opt=foo" -// -// RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID -// CHECK-X86-ANDROID: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" diff --git a/clang/test/Driver/lto-plugin-darwin.c b/clang/test/Driver/lto-plugin-darwin.c deleted file mode 100644 index 2e9e6ba..0000000 --- a/clang/test/Driver/lto-plugin-darwin.c +++ /dev/null @@ -1,6 +0,0 @@ -// Check that Darwin uses LLVMgold.dylib. -// REQUIRES: system-darwin -// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s -// -// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib" diff --git a/clang/test/Driver/lto-plugin-linux.c b/clang/test/Driver/lto-plugin-linux.c deleted file mode 100644 index ac1eb14..0000000 --- a/clang/test/Driver/lto-plugin-linux.c +++ /dev/null @@ -1,6 +0,0 @@ -// Check that non-Windows, non-Darwin OSs use LLVMgold.so. -// REQUIRES: !system-darwin && !system-windows -// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s -// -// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so" diff --git a/clang/test/Driver/lto-plugin-windows.c b/clang/test/Driver/lto-plugin-windows.c deleted file mode 100644 index 1b12702..0000000 --- a/clang/test/Driver/lto-plugin-windows.c +++ /dev/null @@ -1,6 +0,0 @@ -// Check that Windows uses LLVMgold.dll. -// REQUIRES: system-windows -// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s -// -// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}\\LLVMgold.dll" diff --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c index 570c80b..becaa9e 100644 --- a/clang/test/Driver/lto.c +++ b/clang/test/Driver/lto.c @@ -32,23 +32,18 @@ // RUN: not %clang %s -emit-llvm 2>&1 | FileCheck --check-prefix=LLVM-LINK %s // LLVM-LINK: -emit-llvm cannot be used when linking -// -flto should cause link using gold plugin -// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s -// -// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" - -// -flto=full should cause link using gold plugin -// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s -// -// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" - -// Check that subsequent -fno-lto takes precedence -// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s -// -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" +/// With ld.bfd or gold, link against LLVMgold. +// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s +// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s +// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=gold -fno-lto -flto -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s +// LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" + +// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s +// NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" // -flto passes along an explicit debugger tuning argument. // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t diff --git a/clang/test/Driver/lto.cu b/clang/test/Driver/lto.cu index 821dfcd..d3d71f3 100644 --- a/clang/test/Driver/lto.cu +++ b/clang/test/Driver/lto.cu @@ -47,26 +47,19 @@ // RUN: | FileCheck --check-prefix=LLVM-LINK %s // LLVM-LINK: -emit-llvm cannot be used when linking -// -flto should cause link using gold plugin -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s +/// With ld.bfd or gold, link against LLVMgold. +// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s +// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s // -// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" - -// -flto=full should cause link using gold plugin -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto=full 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s -// -// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" +// LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" // Check that subsequent -fno-lto takes precedence -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s +// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \ +// RUN: -fuse-ld=gold -flto=full -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s // -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" +// NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" // -flto passes along an explicit debugger tuning argument. // RUN: %clangxx -nocudainc -nocudalib \ diff --git a/clang/test/Driver/thinlto.c b/clang/test/Driver/thinlto.c index bef7b2b..e08435f 100644 --- a/clang/test/Driver/thinlto.c +++ b/clang/test/Driver/thinlto.c @@ -13,25 +13,3 @@ // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir // CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc // CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image - -// -flto=thin should cause link using gold plugin with thinlto option, -// also confirm that it takes precedence over earlier -fno-lto and -flto=full. -// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s -// -// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto" - -// Check that subsequent -flto=full takes precedence -// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s -// -// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto" - -// Check that subsequent -fno-lto takes precedence -// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s -// -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto" diff --git a/clang/test/Driver/thinlto.cu b/clang/test/Driver/thinlto.cu index c5a76b0..bd13e2e3 100644 --- a/clang/test/Driver/thinlto.cu +++ b/clang/test/Driver/thinlto.cu @@ -27,28 +27,3 @@ // CHECK-COMPILELINK-ACTIONS: 11: offload, "host-cuda {{.*}}" {2}, "device-cuda{{.*}}" {10}, ir // CHECK-COMPILELINK-ACTIONS: 12: backend, {11}, lto-bc, (host-cuda) // CHECK-COMPILELINK-ACTIONS: 13: linker, {12}, image, (host-cuda) - -// -flto=thin should cause link using gold plugin with thinlto option, -// also confirm that it takes precedence over earlier -fno-lto and -flto=full. -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s -// -// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto" - -// Check that subsequent -flto=full takes precedence -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s -// -// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto" - -// Check that subsequent -fno-lto takes precedence -// RUN: %clangxx -nocudainc -nocudalib \ -// RUN: -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s -// -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" -// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto" |