@@ -570,13 +570,13 @@ bool CIRGenModule::shouldEmitCUDAGlobalVar(const VarDecl *global) const {
570
570
// their device-side incarnations.
571
571
572
572
if (global->hasAttr <CUDAConstantAttr>() ||
573
- 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 <CUDASharedAttr>();
578
+ global->hasAttr <CUDASharedAttr>() ||
579
+ global->getType ()->isCUDADeviceBuiltinSurfaceType ();
580
580
}
581
581
582
582
void CIRGenModule::emitGlobal (GlobalDecl gd) {
@@ -1122,10 +1122,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
1122
1122
}
1123
1123
}
1124
1124
1125
- // TODO(cir): LLVM codegen makes sure the result is of the correct type
1126
- // by issuing a address space cast.
1127
- if (entryCIRAS != cirAS)
1128
- llvm_unreachable (" NYI" );
1125
+ // Address space check removed because it is unnecessary because CIR records
1126
+ // address space info in types.
1129
1127
1130
1128
// (If global is requested for a definition, we always need to create a new
1131
1129
// global, not just return a bitcast.)
@@ -1496,7 +1494,8 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
1496
1494
// __shared__ variables is not marked as externally initialized,
1497
1495
// because they must not be initialized.
1498
1496
if (linkage != cir::GlobalLinkageKind::InternalLinkage &&
1499
- (d->hasAttr <CUDADeviceAttr>())) {
1497
+ (d->hasAttr <CUDADeviceAttr>() ||
1498
+ d->getType ()->isCUDADeviceBuiltinSurfaceType ())) {
1500
1499
gv->setAttr (CUDAExternallyInitializedAttr::getMnemonic (),
1501
1500
CUDAExternallyInitializedAttr::get (&getMLIRContext ()));
1502
1501
}
0 commit comments