@@ -570,13 +570,13 @@ bool CIRGenModule::shouldEmitCUDAGlobalVar(const VarDecl *global) const {
570570 // their device-side incarnations.
571571
572572 if (global->hasAttr <CUDAConstantAttr>() ||
573- global->getType ()->isCUDADeviceBuiltinSurfaceType () ||
574573 global->getType ()->isCUDADeviceBuiltinTextureType ()) {
575574 llvm_unreachable (" NYI" );
576575 }
577576
578577 return !langOpts.CUDAIsDevice || global->hasAttr <CUDADeviceAttr>() ||
579- global->hasAttr <CUDASharedAttr>();
578+ global->hasAttr <CUDASharedAttr>() ||
579+ global->getType ()->isCUDADeviceBuiltinSurfaceType ();
580580}
581581
582582void CIRGenModule::emitGlobal (GlobalDecl gd) {
@@ -1122,10 +1122,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
11221122 }
11231123 }
11241124
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.
11291127
11301128 // (If global is requested for a definition, we always need to create a new
11311129 // global, not just return a bitcast.)
@@ -1496,7 +1494,8 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
14961494 // __shared__ variables is not marked as externally initialized,
14971495 // because they must not be initialized.
14981496 if (linkage != cir::GlobalLinkageKind::InternalLinkage &&
1499- (d->hasAttr <CUDADeviceAttr>())) {
1497+ (d->hasAttr <CUDADeviceAttr>() ||
1498+ d->getType ()->isCUDADeviceBuiltinSurfaceType ())) {
15001499 gv->setAttr (CUDAExternallyInitializedAttr::getMnemonic (),
15011500 CUDAExternallyInitializedAttr::get (&getMLIRContext ()));
15021501 }
0 commit comments