1 // -flto causes a switch to llvm-bc object files. 2 // RUN: %clang -ccc-print-phases -c %s -flto 2> %t 3 // RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s 4 // 5 // CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir 6 // CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc 7 8 // RUN: %clang -ccc-print-phases %if target={{.*-windows-msvc.*}} %{ -fuse-ld=lld %} -flto %s 2> %t 9 // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s 10 // 11 // CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}lto.c", c 12 // CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output 13 // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir 14 // CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc 15 // CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image 16 17 // llvm-bc and llvm-ll outputs need to match regular suffixes 18 // (unfortunately). 19 // RUN: %clang --target=x86_64-linux-gnu %s -flto -save-temps -### 2> %t 20 // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s 21 // 22 // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.i" "-x" "c" "{{.*}}lto.c" 23 // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.bc" {{.*}}"{{.*}}lto.i" 24 // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.o" {{.*}}"{{.*}}lto.bc" 25 // CHECK-COMPILELINK-SUFFIXES: "{{.*}}a.{{(out|exe)}}" {{.*}}"{{.*}}lto.o" 26 27 // RUN: %clang --target=x86_64-linux-gnu %s -flto -S -### 2> %t 28 // RUN: FileCheck -check-prefix=CHECK-COMPILE-SUFFIXES < %t %s 29 // 30 // CHECK-COMPILE-SUFFIXES: "-o" "{{.*}}lto.s" "-x" "c" "{{.*}}lto.c" 31 32 // RUN: not %clang %s -emit-llvm 2>&1 | FileCheck --check-prefix=LLVM-LINK %s 33 // LLVM-LINK: -emit-llvm cannot be used when linking 34 35 /// With ld.bfd or gold, link against LLVMgold. 36 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 37 // RUN: -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s 38 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 39 // RUN: -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s 40 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 41 // RUN: -fuse-ld=gold -fno-lto -flto -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s 42 // LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" 43 44 /// lld does not need LLVMgold. 45 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 46 // RUN: -fuse-ld=lld -flto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s 47 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 48 // RUN: -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s 49 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}" 50 51 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 52 // RUN: -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s 53 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 54 // RUN: -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s 55 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 56 // RUN: -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s 57 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 58 // RUN: -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s 59 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 60 // RUN: -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s 61 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 62 // RUN: -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s 63 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 64 // RUN: -fuse-ld=lld -flto -O3 -### 2>&1 | FileCheck --check-prefix=O3 %s 65 // RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \ 66 // RUN: -fuse-ld=lld -flto -Ofast -### 2>&1 | FileCheck --check-prefix=O3 %s 67 68 // O1: -plugin-opt=O1 69 // O2: -plugin-opt=O2 70 // O3: -plugin-opt=O3 71 72 // -flto passes along an explicit debugger tuning argument. 73 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto -glldb 2> %t 74 // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s 75 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto -g 2> %t 76 // RUN: FileCheck -check-prefix=CHECK-NO-TUNING < %t %s 77 // 78 // CHECK-TUNING-LLDB: "-plugin-opt=-debugger-tune=lldb" 79 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune 80 // 81 // -flto=auto and -flto=jobserver pass along -flto=full 82 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=auto 2>&1 | FileCheck --check-prefix=FLTO-AUTO %s 83 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=jobserver 2>&1 | FileCheck --check-prefix=FLTO-JOBSERVER %s 84 // 85 // FLTO-AUTO: -flto=full 86 // FLTO-JOBSERVER: -flto=full 87 // 88 89 // Pass the last -flto argument. 90 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -flto 2>&1 | \ 91 // RUN: FileCheck --check-prefix=FLTO-FULL %s 92 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -flto=full \ 93 // RUN: 2>&1 | FileCheck --check-prefix=FLTO-FULL %s 94 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=full -flto=thin \ 95 // RUN: 2>&1 | FileCheck --check-prefix=FLTO-THIN %s 96 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto -flto=thin 2>&1 | \ 97 // RUN: FileCheck --check-prefix=FLTO-THIN %s 98 // 99 // FLTO-FULL-NOT: -flto=thin 100 // FLTO-FULL: -flto=full 101 // FLTO-FULL-NOT: -flto=thin 102 // 103 // FLTO-THIN-NOT: -flto=full 104 // FLTO-THIN-NOT: "-flto" 105 // FLTO-THIN: -flto=thin 106 // FLTO-THIN-NOT: "-flto" 107 // FLTO-THIN-NOT: -flto=full 108 109 // -flto passes along an explicit GlobalISel flag. 110 // RUN: %clang --target=riscv64-linux-gnu -### %s -flto -fglobal-isel 2> %t 111 // RUN: FileCheck --check-prefix=CHECK-GISEL < %t %s 112 // RUN: %clang --target=aarch64-linux-gnu -### %s -flto -fno-global-isel 2> %t 113 // RUN: FileCheck --check-prefix=CHECK-DISABLE-GISEL < %t %s 114 // 115 // CHECK-GISEL: "-plugin-opt=-global-isel=1" 116 // CHECK-DISABLE-GISEL: "-plugin-opt=-global-isel=0" 117 118 // -flto passes -time-passes when -ftime-report is passed 119 // RUN: %clang --target=x86_64-unknown-linux-gnu -### %s -flto -ftime-report 2> %t 120 // RUN: FileCheck --check-prefix=CHECK-TIME-REPORT < %t %s 121 122 // CHECK-TIME-REPORT: "-plugin-opt=-time-passes" 123