[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

Ole Strohm via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 10 09:08:28 PDT 2021


olestrohm created this revision.
olestrohm added reviewers: Anastasia, svenvh, rjmccall.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch aims to add initial support for multiple address spaced destructors.
Currently this parses fine and the destructors are correctly added to the class,
but there is no logic to choose the correct destructor for a variable in a specific address space.
Currently it always picks the first destructor defined in the source code, regardless of the 
address space of the variable.

This is not aiming to be a complete implementation, as destructors are used in a very large
number of locations, and so doing all of it in one patch would be very difficult to review and code.

The goals for this patch is thus to add basic support for destructors, and to build a framework for
additional work to be done on this front.
Since this feature won't be completed in this patch, I have attempted to ensure that no C++
functionality is changed, to ensure that the changes will only affect C++ for OpenCL.
This also has the effect that whenever destructors aren't correctly implemented it will fallback
to default behaviour, which is exactly the same currently happens.

In summary destructors in C++ for OpenCL are currently unusable for multiple destructors. With
this patch the feature will be usable in the most common situation, and every bug that currently 
exists that isn't covered by the changes I have made here will continue to be bugs. The hope is that
this patch therefore is almost entirely a positive, since while it doesn't fix every bug, it will make the
feature actually work, and will create a base to fix the other bugs as they are discovered.

This is why it's mostly implemented through default parameters, as that will allow this change to
remain as small as it is, while also allowing further fixes to come along later.

The feature is also C++ for OpenCL specific to let the fast path remain when not utilizing the
address spaces, as this new implementation will be slower than the bitfields that C++ currently
uses, but I hope this can also be optimized in the future if it turns out to be very slow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109609

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109609.371935.patch
Type: text/x-patch
Size: 12684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210910/1a1f50ba/attachment.bin>


More information about the cfe-commits mailing list