summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCUDA.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [CUDA] Use the multi-element remove function in EraseUnwantedCUDAMatches.Justin Lebar2016-07-121-2/+4
| | | | | | | | | | | | | | | | Summary: Bug pointed out by Benjamin Kramer in r264008. I think the bug is benign because by the time this is called, we should only have at most two overloads to consider (either a host and a device overload, or a host+device overload, but not all three). Reviewers: tra Subscribers: cfe-commits, bkramer Differential Revision: http://reviews.llvm.org/D21914 llvm-svn: 275233
* [CUDA] Do not allow non-empty destructors for global device-side variables.Artem Belevich2016-05-191-1/+49
| | | | | | | | | | | | | | According to Cuda Programming guide (v7.5, E2.3.1): > __device__, __constant__ and __shared__ variables defined in namespace > scope, that are of class type, cannot have a non-empty constructor or a > non-empty destructor. Clang already deals with device-side constructors (see D15305). This patch enforces similar rules for destructors. Differential Revision: http://reviews.llvm.org/D20140 llvm-svn: 270108
* [CUDA] Make unattributed constexpr functions implicitly host+device.Justin Lebar2016-03-301-1/+50
| | | | | | | | | | | | | | | | | | | | | | | | With this patch, by a constexpr function is implicitly host+device unless: a) it's a variadic function (variadic functions are not allowed on the device side), or b) it's preceeded by a __device__ overload in a system header. The restriction on overloading __host__ __device__ functions on the basis of their CUDA attributes remains in place, but we use (b) to allow us to define __device__ overloads for constexpr functions in cmath, which would otherwise be __host__ __device__ and thus not overloadable. You can disable this behavior with -fno-cuda-host-device-constexpr. Reviewers: tra, rnk, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18380 llvm-svn: 264964
* [CUDA] Fix order of overloading preferences in comment.Justin Lebar2016-03-291-1/+1
| | | | llvm-svn: 264741
* [CUDA] Remove three obsolete CUDA cc1 flags.Justin Lebar2016-03-291-74/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: * -fcuda-target-overloads Previously unconditionally set to true by the driver. Necessary for correct functioning of the compiler -- our CUDA headers wrapper won't compile without this. * -fcuda-disable-target-call-checks Previously unconditionally set to true by the driver. Necessary to compile almost any external CUDA code -- almost all libraries assume that host+device code can call host or device functions. * -fcuda-allow-host-calls-from-host-device No effect when target overloading is enabled. Reviewers: tra Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D18416 llvm-svn: 264739
* [sema] [CUDA] Use std algorithms in EraseUnwantedCUDAMatchesImpl.Justin Lebar2016-03-221-17/+14
| | | | | | | | | | | | Summary: NFC Reviewers: tra Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18327 llvm-svn: 264008
* [CUDA] Tweak attribute-based overload resolution to match nvcc behavior.Artem Belevich2016-02-121-40/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an artefact of split-mode CUDA compilation that we need to mimic. HD functions are sometimes allowed to call H or D functions. Due to split compilation mode device-side compilation will not see host-only function and thus they will not be considered at all. For clang both H and D variants will become function overloads visible to compiler. Normally target attribute is considered only if C++ rules can not determine which function is better. However in this case we need to ignore functions that would not be present during current compilation phase before we apply normal overload resolution rules. Changes: * introduced another level of call preference to better describe possible call combinations. * removed WrongSide functions from consideration if the set contains SameSide function. * disabled H->D, D->H and G->H calls. These combinations are not allowed by CUDA and we were reluctantly allowing them to work around device-side calls to math functions in std namespace. We no longer need it after r258880. Differential Revision: http://reviews.llvm.org/D16870 llvm-svn: 260697
* [CUDA] Do not allow dynamic initialization of global device side variables.Artem Belevich2016-02-021-0/+35
| | | | | | | | | | | | | | In general CUDA does not allow dynamic initialization of global device-side variables. One exception is that CUDA allows records with empty constructors as described in section E2.2.1 of CUDA 7.5 Programming guide. This patch applies initializer checks for all device-side variables. Empty constructors are accepted, but no code is generated for them. Differential Revision: http://reviews.llvm.org/D15305 llvm-svn: 259592
* [CUDA] Only allow __global__ on free functions and static member functions.Justin Lebar2016-01-201-6/+3
| | | | | | | | | | | | | | Summary: Warn for NVCC compatibility if you declare a static member function or inline function as __global__. Reviewers: tra Subscribers: jhen, echristo, cfe-commits Differential Revision: http://reviews.llvm.org/D16261 llvm-svn: 258263
* [CUDA] Allow function overloads in CUDA based on host/device attributes.Artem Belevich2015-09-221-0/+144
| | | | | | | | | | | | | | | | | | | The patch makes it possible to parse CUDA files that contain host/device functions with identical signatures, but different attributes without having to physically split source into host-only and device-only parts. This change is needed in order to parse CUDA header files that have a lot of name clashes with standard include files. Gory details are in design doc here: https://goo.gl/EXnymm Feel free to leave comments there or in this review thread. This feature is controlled with CC1 option -fcuda-target-overloads and is disabled by default. Differential Revision: http://reviews.llvm.org/D12453 llvm-svn: 248295
* Create a frontend flag to disable CUDA cross-target call checksEli Bendersky2015-04-151-0/+5
| | | | | | | | | | | | | | | For CUDA source, Sema checks that the targets of call expressions make sense (e.g. a host function can't call a device function). Adding a flag that lets us skip this check. Motivation: for source-to-source translation tools that have to accept code that's not strictly kosher CUDA but is still accepted by nvcc. The source-to-source translation tool can then fix the code and leave calls that are semantically valid for the actual compilation stage. Differential Revision: http://reviews.llvm.org/D9036 llvm-svn: 235049
* CUDA: Add option to allow host device functions to call host functionsJacques Pienaar2015-02-241-2/+14
| | | | | | Commiting code from review http://reviews.llvm.org/D7841 llvm-svn: 230385
* Consider calls from implict host device functions as valid in SemaCUDA.Jacques Pienaar2014-12-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | In SemaCUDA all implicit functions were considered host device, this led to errors such as the following code snippet failing to compile: struct Copyable { const Copyable& operator=(const Copyable& x) { return *this; } }; struct Simple { Copyable b; }; void foo() { Simple a, b; a = b; } Above the implicit copy assignment operator was inferred as host device but there was only a host assignment copy defined which is an error in device compilation mode. Differential Revision: http://reviews.llvm.org/D6565 llvm-svn: 224358
* CUDA host device code with two code pathsReid Kleckner2014-12-031-5/+14
| | | | | | | | | | | | | | | | | | | | | | | Summary: Allow CUDA host device functions with two code paths using __CUDA_ARCH__ to differentiate between code path being compiled. For example: __host__ __device__ void host_device_function(void) { #ifdef __CUDA_ARCH__ device_only_function(); #else host_only_function(); #endif } Patch by Jacques Pienaar. Reviewed By: rnk Differential Revision: http://reviews.llvm.org/D6457 llvm-svn: 223271
* CUDA: mark the target of implicit intrinsics properlyEli Bendersky2014-09-301-0/+6
| | | | | | | | | | | | | r218624 implemented target inference for implicit special members. However, other entities can be implicit - for example intrinsics. These can not have inference running on them, so they should be marked host device as before. This is the safest and most flexible setting, since by construction these functions don't invoke anything, and we'd like them to be invokable from both host and device code. LLVM's intrinsics definitions (where these intrinsics come from in the case of CUDA/NVPTX) have no notion of target, so both host and device intrinsics can be supported this way. llvm-svn: 218688
* CUDA: Fix incorrect target inference for implicit members.Eli Bendersky2014-09-291-4/+176
| | | | | | | | | | | | As PR20495 demonstrates, Clang currenlty infers the CUDA target (host/device, etc) for implicit members (constructors, etc.) incorrectly. This causes errors and even assertions in Clang when compiling code (assertions in C++11 mode where implicit move constructors are added into the mix). Fix the problem by inferring the target from the methods the implicit member should call (depending on its base classes and fields). llvm-svn: 218624
* Split off CUDA-specific Sema parts to a new fileEli Bendersky2014-09-031-0/+76
In line with SemaOpenMP.cpp, etc. CUDA-specific semantic analysis code goes into a separate file. This is in anticipation of adding extra functionality here in the near future. No change in functionality. Review: http://reviews.llvm.org/D5160 llvm-svn: 217043
OpenPOWER on IntegriCloud