[Driver][test] Refactor LLVMgold tests
authorFangrui Song <maskray@google.com>
Sat, 8 Feb 2020 05:42:14 +0000 (21:42 -0800)
committerFangrui Song <maskray@google.com>
Sat, 8 Feb 2020 06:37:11 +0000 (22:37 -0800)
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

clang/test/Driver/freebsd.c
clang/test/Driver/gold-lto.c [deleted file]
clang/test/Driver/lto-plugin-darwin.c [deleted file]
clang/test/Driver/lto-plugin-linux.c [deleted file]
clang/test/Driver/lto-plugin-windows.c [deleted file]
clang/test/Driver/lto.c
clang/test/Driver/lto.cu
clang/test/Driver/thinlto.c
clang/test/Driver/thinlto.cu

index dc209704d7abc5a24f18b45a2a593ce6688b2a4a..5eb00ce65d711acda918ac30a8f83ffd1c07dede 100644 (file)
 // 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 (file)
index d16961e..0000000
+++ /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 (file)
index 2e9e6ba..0000000
+++ /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 (file)
index ac1eb14..0000000
+++ /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 (file)
index 1b12702..0000000
+++ /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"
index 570c80b94188a04bddd6c5ef69f3bd1384931a81..becaa9e7a0a33f2bb20638c6598ddfed8a7ef4d5 100644 (file)
 // 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
index 821dfcd20319da0e7f3a277fa0be564e87965279..d3d71f305fda4dd65e168f644e407ef0ff4aad61 100644 (file)
 // 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 \
index bef7b2b0a6f127ea955015ae8430ad2fecd3de09..e08435f71cc0b0bea8b0d1d1e3356eee93aca6f5 100644 (file)
 // 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"
index c5a76b0cbdfd64ed0f613e00a13e0767dc530dd6..bd13e2e3b73115d05996b9fd278c1a7a8274109f 100644 (file)
 // 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"