@@ -569,12 +569,12 @@ bool CIRGenModule::shouldEmitCUDAGlobalVar(const VarDecl *global) const {
569
569
// size and host-side address in order to provide access to
570
570
// their device-side incarnations.
571
571
572
- if (global->hasAttr <CUDAConstantAttr>() ||
573
- global->getType ()->isCUDADeviceBuiltinTextureType ()) {
572
+ if (global->getType ()->isCUDADeviceBuiltinTextureType ()) {
574
573
llvm_unreachable (" NYI" );
575
574
}
576
575
577
576
return !langOpts.CUDAIsDevice || global->hasAttr <CUDADeviceAttr>() ||
577
+ global->hasAttr <CUDAConstantAttr>() ||
578
578
global->hasAttr <CUDASharedAttr>() ||
579
579
global->getType ()->isCUDADeviceBuiltinSurfaceType ();
580
580
}
@@ -1492,7 +1492,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
1492
1492
// __shared__ variables is not marked as externally initialized,
1493
1493
// because they must not be initialized.
1494
1494
if (linkage != cir::GlobalLinkageKind::InternalLinkage &&
1495
- (d->hasAttr <CUDADeviceAttr>() ||
1495
+ (d->hasAttr <CUDADeviceAttr>() || d-> hasAttr <CUDAConstantAttr>() ||
1496
1496
d->getType ()->isCUDADeviceBuiltinSurfaceType ())) {
1497
1497
gv->setAttr (CUDAExternallyInitializedAttr::getMnemonic (),
1498
1498
CUDAExternallyInitializedAttr::get (&getMLIRContext ()));
@@ -1505,8 +1505,9 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
1505
1505
emitter->finalize (gv);
1506
1506
1507
1507
// TODO(cir): If it is safe to mark the global 'constant', do so now.
1508
- gv.setConstant (!needsGlobalCtor && !needsGlobalDtor &&
1509
- isTypeConstant (d->getType (), true , true ));
1508
+ gv.setConstant ((d->hasAttr <CUDAConstantAttr>() && langOpts.CUDAIsDevice ) ||
1509
+ (!needsGlobalCtor && !needsGlobalDtor &&
1510
+ isTypeConstant (d->getType (), true , true )));
1510
1511
1511
1512
// If it is in a read-only section, mark it 'constant'.
1512
1513
if (const SectionAttr *sa = d->getAttr <SectionAttr>())
0 commit comments