@@ -569,15 +569,14 @@ 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 (
573
- global->getType ()->isCUDADeviceBuiltinSurfaceType () ||
572
+ if (global->getType ()->isCUDADeviceBuiltinSurfaceType () ||
574
573
global->getType ()->isCUDADeviceBuiltinTextureType ()) {
575
574
llvm_unreachable (" NYI" );
576
575
}
577
576
578
577
return !langOpts.CUDAIsDevice || global->hasAttr <CUDADeviceAttr>() ||
579
- global->hasAttr <CUDAConstantAttr>() ||
580
- global->hasAttr <CUDASharedAttr>();
578
+ global->hasAttr <CUDAConstantAttr>() ||
579
+ global->hasAttr <CUDASharedAttr>();
581
580
}
582
581
583
582
void CIRGenModule::emitGlobal (GlobalDecl gd) {
@@ -1497,7 +1496,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
1497
1496
// __shared__ variables is not marked as externally initialized,
1498
1497
// because they must not be initialized.
1499
1498
if (linkage != cir::GlobalLinkageKind::InternalLinkage &&
1500
- (d->hasAttr <CUDADeviceAttr>())) {
1499
+ (d->hasAttr <CUDADeviceAttr>() || d-> hasAttr <CUDAConstantAttr>() )) {
1501
1500
gv->setAttr (CUDAExternallyInitializedAttr::getMnemonic (),
1502
1501
CUDAExternallyInitializedAttr::get (&getMLIRContext ()));
1503
1502
}
@@ -1511,7 +1510,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
1511
1510
// TODO(cir): If it is safe to mark the global 'constant', do so now.
1512
1511
gv.setConstant ((d->hasAttr <CUDAConstantAttr>() && langOpts.CUDAIsDevice ) ||
1513
1512
(!needsGlobalCtor && !needsGlobalDtor &&
1514
- isTypeConstant (d->getType (), true , true )));
1513
+ isTypeConstant (d->getType (), true , true )));
1515
1514
1516
1515
// If it is in a read-only section, mark it 'constant'.
1517
1516
if (const SectionAttr *sa = d->getAttr <SectionAttr>())
0 commit comments