|
| 1 | +;; Check that the expected Clang arguments are generated by DTLTO for the |
| 2 | +;; backend compilations and are accepted by Clang. |
| 3 | + |
| 4 | +; RUN: rm -rf %t && split-file %s %t && cd %t |
| 5 | + |
| 6 | +;; Generate bitcode files with a summary index. |
| 7 | +; RUN: opt -thinlto-bc x86_64-unknown-linux-gnu.ll -o x86_64-unknown-linux-gnu.bc |
| 8 | +; RUN: opt -thinlto-bc x86_64-pc-windows-msvc.ll -o x86_64-pc-windows-msvc.bc |
| 9 | + |
| 10 | + |
| 11 | +;; Check that any invalid arguments would cause a Clang error. This property is |
| 12 | +;; relied on by the actual testcases later in this test. |
| 13 | +; RUN: not %clang -x ir x86_64-unknown-linux-gnu.ll \ |
| 14 | +; RUN: -invalid-incorrect-not-an-option 2>&1 | FileCheck %s --check-prefix=SANITY1 |
| 15 | +; SANITY1: unknown argument: '-invalid-incorrect-not-an-option' |
| 16 | + |
| 17 | + |
| 18 | +;; Define a substitution used to simplify the testcases. |
| 19 | +; DEFINE: %{distributor} = dummy |
| 20 | +; DEFINE: %{extra_flags} = dummy |
| 21 | +; DEFINE: %{triple} = dummy |
| 22 | +; DEFINE: %{command} = llvm-lto2 run \ |
| 23 | +; DEFINE: -thinlto-distributor-arg=%llvm_src_root/utils/dtlto/%{distributor} \ |
| 24 | +; DEFINE: -thinlto-remote-opt-tool-arg=-Wunused-command-line-argument \ |
| 25 | +; DEFINE: @%{triple}.rsp %{extra_flags} |
| 26 | + |
| 27 | + |
| 28 | +;; Write common arguments to a response files. |
| 29 | + |
| 30 | +; RUN: echo "x86_64-unknown-linux-gnu.bc -o x86_64-unknown-linux-gnu.o \ |
| 31 | +; RUN: -dtlto \ |
| 32 | +; RUN: -dtlto-remote-opt-tool=%clang \ |
| 33 | +; RUN: -thinlto-remote-opt-tool-arg=-Werror \ |
| 34 | +; RUN: -dtlto-distributor=%python \ |
| 35 | +; RUN: -r=x86_64-unknown-linux-gnu.bc,globalfunc1,plx" > x86_64-unknown-linux-gnu.rsp |
| 36 | + |
| 37 | +; RUN: echo "x86_64-pc-windows-msvc.bc -o x86_64-pc-windows-msvc.o \ |
| 38 | +; RUN: -dtlto \ |
| 39 | +; RUN: -dtlto-remote-opt-tool=%clang \ |
| 40 | +; RUN: -thinlto-remote-opt-tool-arg=-Werror \ |
| 41 | +; RUN: -thinlto-remote-opt-tool-arg=-Wno-override-module \ |
| 42 | +; RUN: -dtlto-distributor=%python \ |
| 43 | +; RUN: -r=x86_64-pc-windows-msvc.bc,globalfunc2,plx" > x86_64-pc-windows-msvc.rsp |
| 44 | + |
| 45 | + |
| 46 | +;; Check that boolean configuration states are translated as expected and Clang |
| 47 | +;; accepts them. |
| 48 | + |
| 49 | +; RUN: echo " \ |
| 50 | +; RUN: --addrsig=1 \ |
| 51 | +; RUN: -function-sections=1 \ |
| 52 | +; RUN: -data-sections=1" > on.rsp |
| 53 | + |
| 54 | +; RUN: echo " \ |
| 55 | +; RUN: --addrsig=0 \ |
| 56 | +; RUN: -function-sections=0 \ |
| 57 | +; RUN: -data-sections=0" > off.rsp |
| 58 | + |
| 59 | +;; Perform DTLTO with configuration state set. |
| 60 | +; REDEFINE: %{extra_flags} = @on.rsp |
| 61 | +; REDEFINE: %{distributor} = local.py |
| 62 | +; REDEFINE: %{triple} = x86_64-unknown-linux-gnu |
| 63 | +; RUN: %{command} |
| 64 | +; REDEFINE: %{distributor} = validate.py |
| 65 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=ON \ |
| 66 | +; RUN: --implicit-check-not=-no-pgo-warn-mismatch |
| 67 | +; ON-DAG: "-faddrsig" |
| 68 | +; ON-DAG: "-ffunction-sections" |
| 69 | +; ON-DAG: "-fdata-sections" |
| 70 | + |
| 71 | +;; Perform DTLTO with configuration state unset. |
| 72 | +; REDEFINE: %{extra_flags} = @off.rsp |
| 73 | +; REDEFINE: %{distributor} = local.py |
| 74 | +; RUN: %{command} |
| 75 | +; REDEFINE: %{distributor} = validate.py |
| 76 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=OFF |
| 77 | +; OFF-NOT: --implicit-check-not=--faddrsig |
| 78 | +; OFF-NOT: --implicit-check-not=--ffunction-sections |
| 79 | +; OFF-NOT: --implicit-check-not=--fdata-sections |
| 80 | +; OFF-NOT: --implicit-check-not=-no-pgo-warn-mismatch |
| 81 | + |
| 82 | + |
| 83 | +;; Check optimisation level. |
| 84 | + |
| 85 | +; RUN: llvm-lto2 run \ |
| 86 | +; RUN: -thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ |
| 87 | +; RUN: @x86_64-unknown-linux-gnu.rsp \ |
| 88 | +; RUN: -O3 |
| 89 | + |
| 90 | +; RUN: not llvm-lto2 run \ |
| 91 | +; RUN: -thinlto-distributor-arg=%llvm_src_root/utils/dtlto/validate.py \ |
| 92 | +; RUN: @x86_64-unknown-linux-gnu.rsp \ |
| 93 | +; RUN: -O3 2>&1 | FileCheck %s --check-prefix=OPTLEVEL |
| 94 | +; OPTLEVEL-DAG: "-O3" |
| 95 | + |
| 96 | + |
| 97 | +;; Check relocation model. |
| 98 | + |
| 99 | +; REDEFINE: %{extra_flags} = -relocation-model=pic |
| 100 | +; REDEFINE: %{distributor} = local.py |
| 101 | +; RUN: %{command} |
| 102 | +; REDEFINE: %{distributor} = validate.py |
| 103 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=PIC |
| 104 | +; PIC: -fpic |
| 105 | + |
| 106 | + |
| 107 | +; REDEFINE: %{extra_flags} = -relocation-model=pic |
| 108 | +; REDEFINE: %{distributor} = local.py |
| 109 | +; REDEFINE: %{triple} = x86_64-pc-windows-msvc |
| 110 | +; RUN: %{command} |
| 111 | +; REDEFINE: %{distributor} = validate.py |
| 112 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=NOPIC |
| 113 | +; REDEFINE: %{triple} = x86_64-unknown-linux-gnu |
| 114 | +; NOPIC-NOT: -fpic |
| 115 | + |
| 116 | +;; Check specifying a sample profile. |
| 117 | +; REDEFINE: %{extra_flags} = --lto-sample-profile-file="missing.profdata" |
| 118 | +; REDEFINE: %{distributor} = local.py |
| 119 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=SAMPLE_PROFILE_ERR |
| 120 | +; SAMPLE_PROFILE_ERR: no such file or directory: 'missing.profdata' |
| 121 | +; REDEFINE: %{distributor} = validate.py |
| 122 | +; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=SAMPLE_PROFILE |
| 123 | +; SAMPLE_PROFILE-DAG: "-fprofile-sample-use=missing.profdata" |
| 124 | + |
| 125 | + |
| 126 | +;--- x86_64-unknown-linux-gnu.ll |
| 127 | + |
| 128 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 129 | +target triple = "x86_64-unknown-linux-gnu" |
| 130 | + |
| 131 | +define void @globalfunc1() { |
| 132 | +entry: |
| 133 | + ret void |
| 134 | +} |
| 135 | + |
| 136 | +;--- x86_64-pc-windows-msvc.ll |
| 137 | + |
| 138 | +target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 139 | +target triple = "x86_64-pc-windows-msvc" |
| 140 | + |
| 141 | +define void @globalfunc2() { |
| 142 | +entry: |
| 143 | + ret void |
| 144 | +} |
0 commit comments