-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Don't emit @__cxa_pure_virtual into device code #16231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYCL] Don't emit @__cxa_pure_virtual into device code #16231
Conversation
This special symbol is used to handling calls to pure virtual functions in regular C++ program. However, for SYCL device code we do not have a guarantee that this symbol will be provided by SYCL backend compilers. Considering that pure virtual function call is an undefined behavior anyway, this PR replaces `@__cxa_pure_virtual` uses with `null` during SYCL device compilation to avoid issues with unresolved symbols.
clang/lib/CodeGen/CGVTables.cpp
Outdated
if (!PureVirtualFn) | ||
PureVirtualFn = | ||
getSpecialVirtualFn(CGM.getCXXABI().GetPureVirtualCallName()); | ||
if (!PureVirtualFn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just add this to getSpecialVirtualFn
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, on the one hand, it would also cover deleted virtual functions. On the other hand, the attributes (in form of SYCL properties) for virtual functions that are callable from device cannot be applied to deleted virtual functions so it won't bring any extra benefit.
I think that the code looks cleaner if we move this change. Even though it is now a little bit more complicated to trace what are the special functions which we are ignoring for SYCL device code (because the filtering is within a helper lambda and not directly within an if pure virtual
), the code overall seems cleaner to me anyway (less new { }
).
Moved it in 6eeb45f
I cancelled the latest pre-commit, because I had only changed comments in a test in the latest commit and previous commit had successfully passed pre-commit. I will proceed with merge |
This special symbol is used to handling calls to pure virtual functions in regular C++ program. However, for SYCL device code we do not have a guarantee that this symbol will be provided by SYCL backend compilers.
Considering that pure virtual function call is an undefined behavior anyway, this PR replaces
@__cxa_pure_virtual
uses withnull
during SYCL device compilation to avoid issues with unresolved symbols.