mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
6c86e9160d
Summary: Previously, when you did something not allowed in a host+device function and then caused it to be codegen'ed, we would print out an error telling you that you did something bad, but we wouldn't tell you how we decided that the function needed to be codegen'ed. This change causes us to print out a callstack when emitting deferred errors. This is immensely helpful when debugging highly-templated code, where it's often unclear how a function became known-emitted. We only print the callstack once per function, after we print the all deferred errors. This patch also switches all of our hashtables to using canonical FunctionDecls instead of regular FunctionDecls. This prevents a number of bugs, some of which are caught by tests added here, in which we assume that two FDs for the same function have the same pointer value. Reviewers: rnk Subscribers: cfe-commits, tra Differential Revision: https://reviews.llvm.org/D25704 llvm-svn: 284647
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -fsyntax-only -verify %s
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify %s
|
|
|
|
#include "Inputs/cuda.h"
|
|
|
|
void host() {
|
|
throw NULL;
|
|
try {} catch(void*) {}
|
|
}
|
|
__device__ void device() {
|
|
throw NULL;
|
|
// expected-error@-1 {{cannot use 'throw' in __device__ function}}
|
|
try {} catch(void*) {}
|
|
// expected-error@-1 {{cannot use 'try' in __device__ function}}
|
|
}
|
|
__global__ void kernel() {
|
|
throw NULL;
|
|
// expected-error@-1 {{cannot use 'throw' in __global__ function}}
|
|
try {} catch(void*) {}
|
|
// expected-error@-1 {{cannot use 'try' in __global__ function}}
|
|
}
|
|
|
|
// Check that it's an error to use 'try' and 'throw' from a __host__ __device__
|
|
// function if and only if it's codegen'ed for device.
|
|
|
|
__host__ __device__ void hd1() {
|
|
throw NULL;
|
|
try {} catch(void*) {}
|
|
#ifdef __CUDA_ARCH__
|
|
// expected-error@-3 {{cannot use 'throw' in __host__ __device__ function}}
|
|
// expected-error@-3 {{cannot use 'try' in __host__ __device__ function}}
|
|
#endif
|
|
}
|
|
|
|
// No error, never instantiated on device.
|
|
inline __host__ __device__ void hd2() {
|
|
throw NULL;
|
|
try {} catch(void*) {}
|
|
}
|
|
void call_hd2() { hd2(); }
|
|
|
|
// Error, instantiated on device.
|
|
inline __host__ __device__ void hd3() {
|
|
throw NULL;
|
|
try {} catch(void*) {}
|
|
#ifdef __CUDA_ARCH__
|
|
// expected-error@-3 {{cannot use 'throw' in __host__ __device__ function}}
|
|
// expected-error@-3 {{cannot use 'try' in __host__ __device__ function}}
|
|
#endif
|
|
}
|
|
|
|
__device__ void call_hd3() { hd3(); }
|
|
#ifdef __CUDA_ARCH__
|
|
// expected-note@-2 {{called by 'call_hd3'}}
|
|
#endif
|