[clang] [CIR][Lowering] Handle address space cast in GlobalViewAttr lowering (PR #190197)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 09:41:41 PDT 2026


================
@@ -732,13 +737,20 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::GlobalViewAttr globalAttr) {
   }
 
   if (auto ptrTy = mlir::dyn_cast<cir::PointerType>(globalAttr.getType())) {
+    auto llvmDstTy = converter->convertType<mlir::LLVM::LLVMPointerType>(ptrTy);
+    unsigned dstAddrSpace = llvmDstTy.getAddressSpace();
+
+    if (sourceAddrSpace != dstAddrSpace) {
+      return mlir::LLVM::AddrSpaceCastOp::create(rewriter, parentOp->getLoc(),
----------------
andykaylor wrote:

What happens if the type and the address space are different?

https://github.com/llvm/llvm-project/pull/190197


More information about the cfe-commits mailing list