Skip to content

Commit 69b87cb

Browse files
committed
Address feedbacks
1 parent 925c380 commit 69b87cb

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7183,7 +7183,6 @@ defm sycl_allow_device_image_dependencies: BoolOptionWithoutMarshalling<"f", "sy
71837183
def fsycl_dump_device_code_EQ : Joined<["-"], "fsycl-dump-device-code=">,
71847184
Flags<[NoXarchOption]>,
71857185
HelpText<"Dump device code into the user provided directory.">;
7186-
71877186
} // let Group = sycl_Group
71887187

71897188
// FIXME: -fsycl-explicit-simd is deprecated. remove it when support is dropped.
@@ -8752,11 +8751,9 @@ def fsycl_allow_func_ptr_EQ : Joined<["-"], "fsycl-allow-func-ptr=">,
87528751
"Default is 'off'">;
87538752
def fsycl_allow_func_ptr : Flag<["-"], "fsycl-allow-func-ptr">,
87548753
Alias<fsycl_allow_func_ptr_EQ>, AliasArgs<["labeled"]>,
8755-
Visibility<[ClangOption, CLOption, CC1Option]>,
87568754
HelpText<"Same as -fsycl-allow-func-ptr=labeled.">;
87578755
def fno_sycl_allow_func_ptr : Flag<["-"], "fno-sycl-allow-func-ptr">,
87588756
Alias<fsycl_allow_func_ptr_EQ>, AliasArgs<["off"]>,
8759-
Visibility<[ClangOption, CLOption, CC1Option]>,
87608757
HelpText<"Same as -fsycl-allow-func-ptr=off.">;
87618758
def fenable_sycl_dae : Flag<["-"], "fenable-sycl-dae">,
87628759
HelpText<"Enable Dead Argument Elimination in SPIR kernels">,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5672,9 +5672,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56725672
}
56735673
}
56745674

5675-
if (Arg *A = Args.getLastArg(options::OPT_fsycl_allow_func_ptr_EQ))
5676-
A->render(Args, CmdArgs);
5677-
56785675
Args.AddLastArg(CmdArgs, options::OPT_fsycl_decompose_functor,
56795676
options::OPT_fno_sycl_decompose_functor);
56805677

clang/test/CodeGenSYCL/invoke-function-defined.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,34 @@ using namespace sycl;
99
queue q;
1010

1111
int bar10() { return 10; }
12+
[[intel::device_indirectly_callable]] int bar20() { return 20; }
1213

13-
// CHECK: define linkonce_odr spir_func noundef i32 @{{.*}}invoke_function{{.*}}(ptr noundef nonnull %f)
1414
template <typename Callable>
1515
auto invoke_function(Callable &&f) {
16-
// CHECK: %f.addr = alloca ptr, align 8
17-
// CHECK: %f.addr.ascast = addrspacecast ptr %f.addr to ptr addrspace(4)
18-
// CHECK: store ptr %f, ptr addrspace(4) %f.addr.ascast, align 8
19-
// CHECK: %0 = load ptr, ptr addrspace(4) %f.addr.ascast, align 8
20-
// CHECK: %call = call spir_func noundef i32 %0()
2116
return f();
2217
}
2318

24-
// CHECK: define linkonce_odr spir_func noundef i32 @{{.*}}bar10{{.*}}()
25-
2619
int main() {
2720
kernel_single_task<class KernelName>(
2821
[=]() {
2922
invoke_function(bar10);
23+
invoke_function(bar20);
3024
});
3125
return 0;
3226
}
27+
28+
// CHECK: define dso_local spir_func noundef i32 @{{.*}}bar20{{.*}}()
29+
30+
// CHECK: @_ZZ4mainENKUlvE_clEv
31+
// CHECK: call {{.*}}invoke_function{{.*}}(ptr noundef nonnull @_Z5bar10v)
32+
// CHECK: call {{.*}}invoke_function{{.*}}(ptr noundef nonnull @_Z5bar20v)
33+
34+
// CHECK: define linkonce_odr spir_func noundef i32 @{{.*}}invoke_function{{.*}}(ptr noundef nonnull %f)
35+
// CHECK: %f.addr = alloca ptr, align 8
36+
// CHECK: %f.addr.ascast = addrspacecast ptr %f.addr to ptr addrspace(4)
37+
// CHECK: store ptr %f, ptr addrspace(4) %f.addr.ascast, align 8
38+
// CHECK: %0 = load ptr, ptr addrspace(4) %f.addr.ascast, align 8
39+
// CHECK: %call = call spir_func noundef i32 %0()
40+
41+
42+
// CHECK: define linkonce_odr spir_func noundef i32 @{{.*}}bar10{{.*}}()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=defined -internal-isystem %S/Inputs -fsyntax-only -verify -sycl-std=2020 -std=c++17 %s
2+
3+
#include "sycl.hpp"
4+
5+
template <typename T> SYCL_EXTERNAL void foo(T input);
6+
7+
template <>
8+
void foo(int input) {}
9+
template <>
10+
void foo(double input);
11+
12+
SYCL_EXTERNAL void usage() {
13+
auto FP = &foo<int>;
14+
auto FP1 = &foo<char>; // expected-error {{taking address of a function without a definition and not marked with 'intel::device_indirectly_callable'}}
15+
auto FP2 = &foo<double>;
16+
}
17+
18+
template <>
19+
void foo(double input) {}

clang/test/SemaSYCL/constexpr-function-pointer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -sycl-std=2020 -std=c++17 %s
2-
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=off -fsyntax-only -verify -sycl-std=2020 -std=c++17 %s
1+
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -sycl-std=2020 %s
2+
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=off -fsyntax-only -verify -sycl-std=2020 %s
33

44
// This test checks that the compiler doesn't emit an error when indirect call
55
// was made through a function pointer that is constant expression, and makes

clang/test/SemaSYCL/wrong-address-taking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=labeled -internal-isystem %S/Inputs -fsyntax-only -verify -sycl-std=2020 -std=c++17 %s
2-
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=defined -internal-isystem %S/Inputs -fsyntax-only -verify=defined-func -sycl-std=2020 -std=c++17 %s
1+
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=labeled -internal-isystem %S/Inputs -fsyntax-only -verify -sycl-std=2020 %s
2+
// RUN: %clang_cc1 -fsycl-is-device -fsycl-allow-func-ptr=defined -internal-isystem %S/Inputs -fsyntax-only -verify=defined-func -sycl-std=2020 %s
33

44
#include "sycl.hpp"
55

0 commit comments

Comments
 (0)