File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -1651,7 +1651,8 @@ static void getTrivialDefaultFunctionAttributes(
1651
1651
// AFAIK, neither of them support exceptions in device code.
1652
1652
if (langOpts.SYCLIsDevice )
1653
1653
llvm_unreachable (" NYI" );
1654
- if (langOpts.OpenCL || (langOpts.CUDA && langOpts.CUDAIsDevice )) {
1654
+ if (langOpts.OpenCL ||
1655
+ ((langOpts.CUDA || langOpts.HIP ) && langOpts.CUDAIsDevice )) {
1655
1656
auto noThrow = cir::NoThrowAttr::get (CGM.getBuilder ().getContext ());
1656
1657
funcAttrs.set (noThrow.getMnemonic (), noThrow);
1657
1658
}
Original file line number Diff line number Diff line change @@ -3112,7 +3112,7 @@ void CIRGenModule::emitDeferred(unsigned recursionLimit) {
3112
3112
// Emit CUDA/HIP static device variables referenced by host code only. Note we
3113
3113
// should not clear CUDADeviceVarODRUsedByHost since it is still needed for
3114
3114
// further handling.
3115
- if (getLangOpts ().CUDA && getLangOpts ().CUDAIsDevice &&
3115
+ if (( getLangOpts ().CUDA || getLangOpts (). HIP ) && getLangOpts ().CUDAIsDevice &&
3116
3116
!getASTContext ().CUDADeviceVarODRUsedByHost .empty ()) {
3117
3117
llvm_unreachable (" NYI" );
3118
3118
}
Original file line number Diff line number Diff line change @@ -348,7 +348,11 @@ mlir::Type CIRGenTypes::convertType(QualType T) {
348
348
349
349
// For the device-side compilation, CUDA device builtin surface/texture types
350
350
// may be represented in different types.
351
- if (astContext.getLangOpts ().CUDAIsDevice ) {
351
+ // NOTE: CUDAIsDevice is true when building also HIP code.
352
+ // 1. There is no SurfaceType on HIP,
353
+ // 2. There is Texture memory on HIP but accessing the memory goes through
354
+ // calls to the runtime. e.g. for a 2D: `tex2D<float>(tex, x, y);`
355
+ if (astContext.getLangOpts ().CUDA && astContext.getLangOpts ().CUDAIsDevice ) {
352
356
if (Ty->isCUDADeviceBuiltinSurfaceType () ||
353
357
Ty->isCUDADeviceBuiltinTextureType ())
354
358
llvm_unreachable (" NYI" );
Original file line number Diff line number Diff line change
1
+ #include " ../Inputs/cuda.h"
2
+
3
+ // RUN: %clang_cc1 -triple=amdgcn-amd-amdhsa -x hip -fcuda-is-device \
4
+ // RUN: -fclangir -emit-cir -o - %s | FileCheck %s
5
+
6
+ // This shouldn't emit.
7
+ __host__ void host_fn (int *a, int *b, int *c) {}
8
+
9
+ // CHECK-NOT: cir.func @_Z7host_fnPiS_S_
10
+
11
+ // This should emit as a normal C++ function.
12
+ __device__ void device_fn (int * a, double b, float c) {}
13
+
14
+ // CIR: cir.func @_Z9device_fnPidf
You can’t perform that action at this time.
0 commit comments