Skip to content

Commit 226ed8b

Browse files
authored
[SYCL][Driver] Do not pass -fopenmp-simd to device compilations (#4098)
When -fopenmp-simd is used in conjunction with -fsycl, device compilation should not be passed -fopenmp-simd. Otherwise, it leads to some common cases not being able to be compiled (such as the definition of a function with a long double parameter). This is already done for other OpenMP options.
1 parent 450152d commit 226ed8b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6177,8 +6177,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
61776177
break;
61786178
}
61796179
} else {
6180-
Args.AddLastArg(CmdArgs, options::OPT_fopenmp_simd,
6181-
options::OPT_fno_openmp_simd);
6180+
if (!JA.isDeviceOffloading(Action::OFK_SYCL))
6181+
Args.AddLastArg(CmdArgs, options::OPT_fopenmp_simd,
6182+
options::OPT_fno_openmp_simd);
61826183
Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
61836184
}
61846185

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Check that -fopenmp-simd is NOT passed to the device compilation when
2+
/// used together with -fsycl.
3+
4+
// REQUIRES: clang-driver
5+
6+
// RUN: %clang -c -fsycl -fopenmp-simd -### %s 2>&1 | FileCheck %s
7+
// RUN: %clang -c -fopenmp-simd -fopenmp-version=50 -### %s 2>&1 | FileCheck %s --check-prefix=UNCHANGED
8+
9+
// CHECK-NOT: "-triple" "spir64"{{.*}} "-fsycl-is-device"{{.*}} "-target=spir64"{{.*}} "-fopenmp-simd"{{.*}} "-fopenmp-version=50"
10+
// CHECK: "-triple"{{.*}} "-fsycl-is-host"{{.*}} "-fopenmp-simd"{{.*}}
11+
12+
// UNCHANGED: "-triple"{{.*}} "-fopenmp-simd"{{.*}} "-fopenmp-version=50"{{.*}}
13+
14+
void foo(long double) {}

0 commit comments

Comments
 (0)