Skip to content

Commit 6eb0c72

Browse files
[SYCL] Disable RTTI for SYCL device compilation (#11411)
We do not support RTTI in kernel code. Do not emit type info during SYCL device compilation. This aligns SYCL with other offloading targets like CUDA.
1 parent 229e9c4 commit 6eb0c72

File tree

3 files changed

+7
-40
lines changed

3 files changed

+7
-40
lines changed

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,8 @@ class CodeGenModule : public CodeGenTypeCache {
954954

955955
// Return whether RTTI information should be emitted for this target.
956956
bool shouldEmitRTTI(bool ForEH = false) {
957-
return (ForEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
957+
return (ForEH || getLangOpts().RTTI) && !getLangOpts().SYCLIsDevice &&
958+
!getLangOpts().CUDAIsDevice &&
958959
!(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
959960
getTriple().isNVPTX());
960961
}

clang/test/CodeGenSYCL/simple-sycl-virtual-function.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
// This test checks that the FE generates global variables corresponding to the
2-
// virtual table in the global address space (addrspace(1)) when
3-
// -fsycl-allow-virtual-functions is passed.
1+
// Test verifying that RTTI information is not emitted during SYCL device compilation.
42

5-
// RUN: %clang_cc1 -triple spir64 -fsycl-allow-virtual-functions -fsycl-is-device -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-PTR
6-
// RUN: %clang_cc1 -triple spir64 -fsycl-allow-virtual-functions -fsycl-is-device -fexperimental-relative-c++-abi-vtables -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-REL
3+
// RUN: %clang_cc1 -triple spir64 -fsycl-allow-virtual-functions -fsycl-is-device -emit-llvm %s -o - | FileCheck %s --implicit-check-not _ZTI4Base --implicit-check-not _ZTI8Derived1 -check-prefix VTABLE
4+
// RUN: %clang_cc1 -triple spir64 -fsycl-allow-virtual-functions -fsycl-is-device -fexperimental-relative-c++-abi-vtables -emit-llvm %s -o - | FileCheck %s --implicit-check-not _ZTI4Base --implicit-check-not _ZTI8Derived1
75

8-
// CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external addrspace(1) global [0 x ptr addrspace(4)]
9-
// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global [0 x ptr addrspace(4)]
10-
// CHECK-PTR: @_ZTI4Base = linkonce_odr constant { ptr addrspace(4), ptr } { ptr addrspace(4) getelementptr inbounds (ptr addrspace(4), ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE to ptr addrspace(4)), i64 2)
11-
// CHECK-PTR: @_ZTI8Derived1 = linkonce_odr constant { ptr addrspace(4), ptr, ptr } { ptr addrspace(4) getelementptr inbounds (ptr addrspace(4), ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE to ptr addrspace(4)), i64 2)
12-
// CHECK-REL: @_ZTI4Base = linkonce_odr constant { ptr addrspace(4), ptr } { ptr addrspace(4) getelementptr inbounds (i8, ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE to ptr addrspace(4)), i32 8)
13-
// CHECK-REL: @_ZTI8Derived1 = linkonce_odr constant { ptr addrspace(4), ptr, ptr } { ptr addrspace(4) getelementptr inbounds (i8, ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE to ptr addrspace(4)), i32 8)
6+
// VTABLE: @_ZTV8Derived1 = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN8Derived17displayEv] }, comdat, align 8
7+
// VTABLE: @_ZTV4Base = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN4Base7displayEv] }, comdat, align 8
148

159
SYCL_EXTERNAL bool rand();
1610

clang/test/CodeGenSYCL/virtual-types.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)