[clang] [clang][CodeGen] Fix casting 'AddrLabelExpr' to a differernt addrspace (PR #237887)

Ben Shi via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 19:56:09 PST 2026


================
@@ -582,7 +582,9 @@ class ScalarExprEmitter
   Value *VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   Value *VisitAddrLabelExpr(const AddrLabelExpr *E) {
     llvm::Value *V = CGF.GetAddrOfLabel(E->getLabel());
-    return Builder.CreateBitCast(V, ConvertType(E->getType()));
+    // For some targets (such as AVR), code and data have different addrspaces.
+    return Builder.CreatePointerBitCastOrAddrSpaceCast(
----------------
benshi001 wrote:

I have eliminated the unnecessary bitcast. Thanks!

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


More information about the cfe-commits mailing list