-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Cast to correct address space when a function object is passed (…
…#3303) When a function object is passed as an argument to a call, type mismatches may be address space mismatches and these cannot be bitcast away. Check if it is an address space mismatch and if so, use the appropriate address space cast. Signed-off-by: Premanand M Rao <premanand.m.rao@intel.com>
- Loading branch information
1 parent
c7d8867
commit d7276bf
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// RUN: %clang_cc1 -sycl-std=2020 -fsycl-is-device -fsycl-allow-func-ptr -internal-isystem %S/Inputs -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice -emit-llvm -o - %s | FileCheck %s | ||
|
||
// Test that the type of function object invoked from the kernel has | ||
// the right address space. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace cl::sycl; | ||
queue q; | ||
|
||
// CHECK: define linkonce_odr spir_func i32 @{{.*}}invoke_function{{.*}}(i32 () addrspace(4)* %f) | ||
template <typename Callable> | ||
auto invoke_function(Callable &&f) { | ||
// CHECK: %f.addr = alloca i32 () addrspace(4)*, align 8 | ||
// CHECK: %f.addr.ascast = addrspacecast i32 () addrspace(4)** %f.addr to i32 () addrspace(4)* addrspace(4)* | ||
// CHECK: store i32 () addrspace(4)* %f, i32 () addrspace(4)* addrspace(4)* %f.addr.ascast, align 8 | ||
// CHECK: %0 = load i32 () addrspace(4)*, i32 () addrspace(4)* addrspace(4)* %f.addr.ascast, align 8 | ||
// CHECK: %call = call spir_func addrspace(4) i32 %0() | ||
return f(); | ||
} | ||
|
||
// CHECK: define dso_local spir_func i32 @{{.*}}bar10{{.*}}() | ||
int bar10() { return 10; } | ||
|
||
int main() { | ||
kernel_single_task<class KernelName>( | ||
[=]() { | ||
invoke_function(bar10); | ||
}); | ||
return 0; | ||
} |