https://github.com/elizabethandrews created https://github.com/llvm/llvm-project/pull/68020
None >From d15c78fbce7b00de68fa65976ad86278492c07ed Mon Sep 17 00:00:00 2001 From: Elizabeth Andrews <elizabeth.andr...@intel.com> Date: Mon, 2 Oct 2023 09:36:35 -0700 Subject: [PATCH] [SYCL] Disable RTTI for SYCL device code --- clang/lib/CodeGen/CodeGenModule.h | 1 + clang/test/CodeGenSYCL/virtual-function.cpp | 24 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 clang/test/CodeGenSYCL/virtual-function.cpp diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 073b471c6e3cc11..06aa78ba493ae19 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -935,6 +935,7 @@ class CodeGenModule : public CodeGenTypeCache { // Return whether RTTI information should be emitted for this target. bool shouldEmitRTTI(bool ForEH = false) { return (ForEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice && + !getLangOpts().SYCLIsDevice && !(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice && getTriple().isNVPTX()); } diff --git a/clang/test/CodeGenSYCL/virtual-function.cpp b/clang/test/CodeGenSYCL/virtual-function.cpp new file mode 100644 index 000000000000000..5549f49f397c2be --- /dev/null +++ b/clang/test/CodeGenSYCL/virtual-function.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s + +// Test verifying that RTTI information is not emitted +// during SYCL device compilation. + +// CHECK-NOT: @_ZTI6Struct + +template <typename name, typename Func> +__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) { + kernelFunc(); +} + +struct Struct { + virtual void foo() {} + void bar() {} + +}; + +int main() { + kernel_single_task<class kernel_function>([]() { + Struct S; + S.bar(); }); + return 0; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits