2 /// Perform several driver tests for OpenMP offloading
5 /// ###########################################################################
7 /// Check whether an invalid OpenMP target is specified:
8 // RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
9 // RUN: | FileCheck -check-prefix=CHK-INVALID-TARGET %s
10 // CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
12 /// ###########################################################################
14 /// Check warning for empty -fopenmp-targets
15 // RUN: %clang -### -fopenmp=libomp -fopenmp-targets= %s 2>&1 \
16 // RUN: | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
17 // CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
19 /// ###########################################################################
21 /// Check error for no -fopenmp option
22 // RUN: not %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
23 // RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s
24 // RUN: not %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
25 // RUN: | FileCheck -check-prefix=CHK-NO-FOPENMP %s
26 // CHK-NO-FOPENMP: error: '-fopenmp-targets' must be used in conjunction with a '-fopenmp' option compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'
28 /// ###########################################################################
30 /// Check warning for duplicate offloading targets.
31 // RUN: %clang -### -ccc-print-phases -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu %s 2>&1 \
32 // RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s
33 // CHK-DUPLICATES: warning: OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified; will be ignored
35 /// ###########################################################################
37 /// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 is passed when compiling for the device.
38 // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
39 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
41 // CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-target-device"
43 /// ###########################################################################
45 /// Check -Xopenmp-target -mcpu=pwr7 is passed when compiling for the device.
46 // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
47 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
49 // CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-target-device"
51 /// ##########################################################################
53 /// Check -mcpu=pwr7 is passed to the same triple.
54 // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu --target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
55 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-MCPU-TO-SAME-TRIPLE %s
57 // CHK-FOPENMP-MCPU-TO-SAME-TRIPLE: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-target-device"
59 /// ##########################################################################
61 /// Check -march=pwr7 is NOT passed to nvptx64-nvidia-cuda.
62 // RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --target=powerpc64le-ibm-linux-gnu -march=pwr7 %s 2>&1 \
63 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-MARCH-TO-GPU %s
65 // CHK-FOPENMP-MARCH-TO-GPU-NOT: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-target-device"
67 /// ###########################################################################
69 /// Check -march=pwr7 is NOT passed to x86_64-unknown-linux-gnu.
70 // RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=x86_64-unknown-linux-gnu --target=powerpc64le-ibm-linux-gnu -march=pwr7 %s 2>&1 \
71 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-MARCH-TO-X86 %s
73 // CHK-FOPENMP-MARCH-TO-X86-NOT: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-target-device"
75 /// ###########################################################################
77 /// Check -Xopenmp-target triggers error when multiple triples are used.
78 // RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
79 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
81 // CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce implicit triple value for -Xopenmp-target, specify triple using -Xopenmp-target=<triple>
83 /// ###########################################################################
85 /// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it.
86 // RUN: not %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
87 // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
89 // CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
91 /// ###########################################################################
93 /// Check the phases graph when using a single target, different from the host.
94 /// We should have an offload action joining the host compile and device
95 /// preprocessor and another one joining the device linking outputs to the host
97 // RUN: %clang -ccc-print-phases -fopenmp=libomp --target=powerpc64-ibm-linux-gnu \
98 // RUN: -fopenmp-targets=powerpc64-ibm-linux-gnu %s 2>&1 | FileCheck -check-prefix=CHK-PHASES %s
99 // CHK-PHASES: 0: input, "[[INPUT:.+]]", c, (host-openmp)
100 // CHK-PHASES-NEXT: 1: preprocessor, {0}, cpp-output, (host-openmp)
101 // CHK-PHASES-NEXT: 2: compiler, {1}, ir, (host-openmp)
102 // CHK-PHASES-NEXT: 3: input, "[[INPUT]]", c, (device-openmp)
103 // CHK-PHASES-NEXT: 4: preprocessor, {3}, cpp-output, (device-openmp)
104 // CHK-PHASES-NEXT: 5: compiler, {4}, ir, (device-openmp)
105 // CHK-PHASES-NEXT: 6: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {2}, "device-openmp (powerpc64-ibm-linux-gnu)" {5}, ir
106 // CHK-PHASES-NEXT: 7: backend, {6}, assembler, (device-openmp)
107 // CHK-PHASES-NEXT: 8: assembler, {7}, object, (device-openmp)
108 // CHK-PHASES-NEXT: 9: offload, "device-openmp (powerpc64-ibm-linux-gnu)" {8}, object
109 // CHK-PHASES-NEXT: 10: clang-offload-packager, {9}, image, (device-openmp)
110 // CHK-PHASES-NEXT: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {2}, "device-openmp (powerpc64-ibm-linux-gnu)" {10}, ir
111 // CHK-PHASES-NEXT: 12: backend, {11}, assembler, (host-openmp)
112 // CHK-PHASES-NEXT: 13: assembler, {12}, object, (host-openmp)
113 // CHK-PHASES-NEXT: 14: clang-linker-wrapper, {13}, image, (host-openmp)
115 /// ###########################################################################
117 /// Check the phases when using multiple targets and multiple source files
118 // RUN: %clang -ccc-print-phases -lsomelib -fopenmp=libomp --target=powerpc64-ibm-linux-gnu \
119 // RUN: -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %s 2>&1 | FileCheck -check-prefix=CHK-PHASES-FILES %s
120 // CHK-PHASES-FILES: 0: input, "somelib", object, (host-openmp)
121 // CHK-PHASES-FILES-NEXT: 1: input, "[[INPUT:.+]]", c, (host-openmp)
122 // CHK-PHASES-FILES-NEXT: 2: preprocessor, {1}, cpp-output, (host-openmp)
123 // CHK-PHASES-FILES-NEXT: 3: compiler, {2}, ir, (host-openmp)
124 // CHK-PHASES-FILES-NEXT: 4: input, "[[INPUT]]", c, (device-openmp)
125 // CHK-PHASES-FILES-NEXT: 5: preprocessor, {4}, cpp-output, (device-openmp)
126 // CHK-PHASES-FILES-NEXT: 6: compiler, {5}, ir, (device-openmp)
127 // CHK-PHASES-FILES-NEXT: 7: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {6}, ir
128 // CHK-PHASES-FILES-NEXT: 8: backend, {7}, assembler, (device-openmp)
129 // CHK-PHASES-FILES-NEXT: 9: assembler, {8}, object, (device-openmp)
130 // CHK-PHASES-FILES-NEXT: 10: offload, "device-openmp (powerpc64-ibm-linux-gnu)" {9}, object
131 // CHK-PHASES-FILES-NEXT: 11: input, "[[INPUT]]", c, (device-openmp)
132 // CHK-PHASES-FILES-NEXT: 12: preprocessor, {11}, cpp-output, (device-openmp)
133 // CHK-PHASES-FILES-NEXT: 13: compiler, {12}, ir, (device-openmp)
134 // CHK-PHASES-FILES-NEXT: 14: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {13}, ir
135 // CHK-PHASES-FILES-NEXT: 15: backend, {14}, assembler, (device-openmp)
136 // CHK-PHASES-FILES-NEXT: 16: assembler, {15}, object, (device-openmp)
137 // CHK-PHASES-FILES-NEXT: 17: offload, "device-openmp (x86_64-pc-linux-gnu)" {16}, object
138 // CHK-PHASES-FILES-NEXT: 18: clang-offload-packager, {10, 17}, image, (device-openmp)
139 // CHK-PHASES-FILES-NEXT: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir
140 // CHK-PHASES-FILES-NEXT: 20: backend, {19}, assembler, (host-openmp)
141 // CHK-PHASES-FILES-NEXT: 21: assembler, {20}, object, (host-openmp)
142 // CHK-PHASES-FILES-NEXT: 22: input, "[[INPUT]]", c, (host-openmp)
143 // CHK-PHASES-FILES-NEXT: 23: preprocessor, {22}, cpp-output, (host-openmp)
144 // CHK-PHASES-FILES-NEXT: 24: compiler, {23}, ir, (host-openmp)
145 // CHK-PHASES-FILES-NEXT: 25: input, "[[INPUT]]", c, (device-openmp)
146 // CHK-PHASES-FILES-NEXT: 26: preprocessor, {25}, cpp-output, (device-openmp)
147 // CHK-PHASES-FILES-NEXT: 27: compiler, {26}, ir, (device-openmp)
148 // CHK-PHASES-FILES-NEXT: 28: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {24}, "device-openmp (powerpc64-ibm-linux-gnu)" {27}, ir
149 // CHK-PHASES-FILES-NEXT: 29: backend, {28}, assembler, (device-openmp)
150 // CHK-PHASES-FILES-NEXT: 30: assembler, {29}, object, (device-openmp)
151 // CHK-PHASES-FILES-NEXT: 31: offload, "device-openmp (powerpc64-ibm-linux-gnu)" {30}, object
152 // CHK-PHASES-FILES-NEXT: 32: input, "[[INPUT]]", c, (device-openmp)
153 // CHK-PHASES-FILES-NEXT: 33: preprocessor, {32}, cpp-output, (device-openmp)
154 // CHK-PHASES-FILES-NEXT: 34: compiler, {33}, ir, (device-openmp)
155 // CHK-PHASES-FILES-NEXT: 35: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {24}, "device-openmp (x86_64-pc-linux-gnu)" {34}, ir
156 // CHK-PHASES-FILES-NEXT: 36: backend, {35}, assembler, (device-openmp)
157 // CHK-PHASES-FILES-NEXT: 37: assembler, {36}, object, (device-openmp)
158 // CHK-PHASES-FILES-NEXT: 38: offload, "device-openmp (x86_64-pc-linux-gnu)" {37}, object
159 // CHK-PHASES-FILES-NEXT: 39: clang-offload-packager, {31, 38}, image, (device-openmp)
160 // CHK-PHASES-FILES-NEXT: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {24}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, ir
161 // CHK-PHASES-FILES-NEXT: 41: backend, {40}, assembler, (host-openmp)
162 // CHK-PHASES-FILES-NEXT: 42: assembler, {41}, object, (host-openmp)
163 // CHK-PHASES-FILES-NEXT: 43: clang-linker-wrapper, {0, 21, 42}, image, (host-openmp)
165 /// Check -fopenmp-is-target-device is passed when compiling for the device.
166 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
167 // RUN: | FileCheck -check-prefix=CHK-fopenmp-is-target-device %s
169 // CHK-fopenmp-is-target-device: "-cc1"{{.*}} "-aux-triple" "powerpc64le-unknown-linux" {{.*}}"-fopenmp-is-target-device" "-fopenmp-host-ir-file-path" {{.*}}.c"
171 /// Check arguments to the linker wrapper
172 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
173 // RUN: | FileCheck -check-prefix=CHK-NEW-DRIVER %s
175 // CHK-NEW-DRIVER: clang-linker-wrapper{{.*}}"--host-triple=powerpc64le-unknown-linux"{{.*}}--{{.*}}"-lomp"{{.*}}"-lomptarget"
177 /// Check arguments to the linker wrapper
178 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -g %s 2>&1 \
179 // RUN: | FileCheck -check-prefix=CHK-NEW-DRIVER-DEBUG %s
181 // CHK-NEW-DRIVER-DEBUG: clang-linker-wrapper{{.*}} "--device-debug"
183 /// Check arguments to the linker wrapper
184 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu \
185 // RUN: -mllvm -abc %s 2>&1 | FileCheck -check-prefix=CHK-NEW-DRIVER-MLLVM %s
187 // CHK-NEW-DRIVER-MLLVM: clang-linker-wrapper{{.*}} "-abc"
190 // Ensure that we generate the correct bindings for '-fsyntax-only' for OpenMP.
192 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu \
193 // RUN: -fsyntax-only -ccc-print-bindings %s 2>&1 | FileCheck -check-prefix=CHK-SYNTAX-ONLY %s
194 // CHK-SYNTAX-ONLY: # "powerpc64le-ibm-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: (nothing)
195 // CHK-SYNTAX-ONLY: # "powerpc64le-unknown-linux" - "clang", inputs: ["[[INPUT]]", (nothing)], output: (nothing)
198 // Ensure that we can generate the correct arguments for '-fsyntax-only' for
201 // RUN: %clang -### --target=powerpc64le-linux -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu \
202 // RUN: -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHK-SYNTAX-ONLY-ARGS %s
203 // CHK-SYNTAX-ONLY-ARGS: "-cc1" "-triple" "powerpc64le-ibm-linux-gnu"{{.*}}"-fsyntax-only"
204 // CHK-SYNTAX-ONLY-ARGS: "-cc1" "-triple" "powerpc64le-unknown-linux"{{.*}}"-fsyntax-only"