@@ -516,16 +516,32 @@ void CIRGenModule::emitGlobal(GlobalDecl GD) {
516
516
assert (!Global->hasAttr <CPUDispatchAttr>() && " NYI" );
517
517
518
518
if (langOpts.CUDA ) {
519
- if (langOpts.CUDAIsDevice )
520
- llvm_unreachable (" NYI" );
519
+ if (langOpts.CUDAIsDevice ) {
520
+ // This will implicitly mark templates and their
521
+ // specializations as __host__ __device__.
522
+ if (langOpts.OffloadImplicitHostDeviceTemplates )
523
+ llvm_unreachable (" NYI" );
521
524
522
- if (dyn_cast<VarDecl>(Global))
523
- llvm_unreachable (" NYI" );
525
+ // This maps some parallel standard libraries implicitly
526
+ // to GPU, even when they are not marked __device__.
527
+ if (langOpts.HIPStdPar )
528
+ llvm_unreachable (" NYI" );
524
529
525
- // We must skip __device__ functions when compiling for host.
526
- if (!Global->hasAttr <CUDAHostAttr>() && Global->hasAttr <CUDADeviceAttr>()) {
527
- return ;
530
+ if (Global->hasAttr <CUDAGlobalAttr>())
531
+ llvm_unreachable (" NYI" );
532
+
533
+ if (!Global->hasAttr <CUDADeviceAttr>())
534
+ return ;
535
+ } else {
536
+ // We must skip __device__ functions when compiling for host.
537
+ if (!Global->hasAttr <CUDAHostAttr>() &&
538
+ Global->hasAttr <CUDADeviceAttr>()) {
539
+ return ;
540
+ }
528
541
}
542
+
543
+ if (dyn_cast<VarDecl>(Global))
544
+ llvm_unreachable (" NYI" );
529
545
}
530
546
531
547
if (langOpts.OpenMP ) {
@@ -2415,8 +2431,6 @@ StringRef CIRGenModule::getMangledName(GlobalDecl GD) {
2415
2431
}
2416
2432
}
2417
2433
2418
- assert (!langOpts.CUDAIsDevice && " NYI" );
2419
-
2420
2434
// Keep the first result in the case of a mangling collision.
2421
2435
const auto *ND = cast<NamedDecl>(GD.getDecl ());
2422
2436
std::string MangledName = getMangledNameImpl (*this , GD, ND);
@@ -3099,7 +3113,8 @@ void CIRGenModule::emitDeferred(unsigned recursionLimit) {
3099
3113
// Emit CUDA/HIP static device variables referenced by host code only. Note we
3100
3114
// should not clear CUDADeviceVarODRUsedByHost since it is still needed for
3101
3115
// further handling.
3102
- if (getLangOpts ().CUDA && getLangOpts ().CUDAIsDevice ) {
3116
+ if (getLangOpts ().CUDA && getLangOpts ().CUDAIsDevice &&
3117
+ !getASTContext ().CUDADeviceVarODRUsedByHost .empty ()) {
3103
3118
llvm_unreachable (" NYI" );
3104
3119
}
3105
3120
@@ -3392,10 +3407,6 @@ void CIRGenModule::Release() {
3392
3407
llvm_unreachable (" NYI" );
3393
3408
}
3394
3409
3395
- if (langOpts.CUDAIsDevice && getTriple ().isNVPTX ()) {
3396
- llvm_unreachable (" NYI" );
3397
- }
3398
-
3399
3410
if (langOpts.EHAsynch )
3400
3411
llvm_unreachable (" NYI" );
3401
3412
0 commit comments