[clang] [CIR] Use data size in emitAggregateCopy for overlapping copies (PR #186702)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 5 03:56:40 PDT 2026


================
@@ -1244,16 +1244,26 @@ void CIRGenFunction::emitAggregateCopy(LValue dest, LValue src, QualType ty,
 
   assert(!cir::MissingFeatures::aggValueSlotVolatile());
 
-  // NOTE(cir): original codegen would normally convert destPtr and srcPtr to
-  // i8* since memcpy operates on bytes. We don't need that in CIR because
-  // cir.copy will operate on any CIR pointer that points to a sized type.
-
   // Don't do any of the memmove_collectable tests if GC isn't set.
   if (cgm.getLangOpts().getGC() != LangOptions::NonGC)
     cgm.errorNYI("emitAggregateCopy: GC");
 
-  [[maybe_unused]] cir::CopyOp copyOp =
-      builder.createCopy(destPtr.getPointer(), srcPtr.getPointer(), isVolatile);
+  // If the data size (excluding tail padding) differs from the full type size,
+  // we can't use cir.copy (which always copies the full pointee type). Instead,
----------------
xlauko wrote:

@erichkeane what do you think now?

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


More information about the cfe-commits mailing list