[clang] [CIR] Upstream `AddressSpace` conversions support (PR #161212)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 16:11:22 PDT 2025


================
@@ -1191,7 +1193,16 @@ LValue CIRGenFunction::emitCastLValue(const CastExpr *e) {
   case CK_Dynamic:
   case CK_ToUnion:
   case CK_BaseToDerived:
-  case CK_AddressSpaceConversion:
+  case CK_AddressSpaceConversion: {
+    LValue lv = emitLValue(e->getSubExpr());
+    QualType destTy = getContext().getPointerType(e->getType());
+    mlir::Value v = getTargetHooks().performAddrSpaceCast(
----------------
andykaylor wrote:

The change in function signature for `perfromAddrSpaceCast` relative to the incubator and classic codegen makes me nervous.

Both the incubator and classic codegen get the source address space here from `E->getSubExpr()->getType().getAddressSpace()`. I would expect you'll get the same address space, though much less directly, with the way you've implemented this. However, there are other places where `performAddrSpaceCast` is called with an address space that didn't come directly from a value, which could be a problem.

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


More information about the cfe-commits mailing list