Skip to content

Commit 90e0e65

Browse files
authored
[clang][SYCL] Disable force inlining of kernel call operator for FGPA (#8688)
In some cases force inlining can remove necessary FPGA metadata. This happened with `ivdep` attribute attached to `do .. while(1)` loop.
1 parent dbde93f commit 90e0e65

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5147,7 +5147,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51475147
// At -O0, disable the inlining for debugging purposes.
51485148
if (!Args.hasFlag(options::OPT_fsycl_force_inline_kernel_lambda,
51495149
options::OPT_fno_sycl_force_inline_kernel_lambda,
5150-
!DisableSYCLForceInlineKernelLambda))
5150+
!DisableSYCLForceInlineKernelLambda &&
5151+
!IsFPGASYCLOffloadDevice))
51515152
CmdArgs.push_back("-fno-sycl-force-inline-kernel-lambda");
51525153

51535154
// Add -ffine-grained-bitfield-accesses option. This will be added
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang++ -fsycl-device-only -fintelfpga -S %s -o - | FileCheck %s
2+
3+
#include "Inputs/sycl.hpp"
4+
5+
// This test checks that FPGA loop metadata is not lost due to optimizations.
6+
7+
int main() {
8+
sycl::queue q;
9+
q.submit([&](sycl::handler &cgh) {
10+
cgh.single_task<class ivdep>([=](){
11+
int m = 16;
12+
int i = 0;
13+
int b = 1;
14+
// CHECK: {!"llvm.loop.ivdep.enable"}
15+
[[intel::ivdep]] do {
16+
if (i >= m) {
17+
break;
18+
} else {
19+
int b = b *2;
20+
}
21+
++i;
22+
} while (1);
23+
});
24+
});
25+
return 0;
26+
}

clang/test/Driver/sycl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
// RUN: %clang_cl -### -fsycl-device-only -Od %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
8080
// RUN: %clangxx -### -fsycl-device-only -O1 %s 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
8181
// RUN: %clang_cl -### -fsycl-device-only -O2 %s 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
82+
// RUN: %clangxx -### -fsycl-device-only -fintelfpga %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
8283
// CHECK-NOT-INLINE: "-fno-sycl-force-inline-kernel-lambda"
8384
// CHECK-INLINE-NOT: "-fno-sycl-force-inline-kernel-lambda"
8485

0 commit comments

Comments
 (0)