[clang] [CIR] Emit memset when zero-initalizing a big struct (PR #244282)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 19 16:56:57 PST 2026
================
@@ -1315,7 +1315,53 @@ AggValueSlot::Overlap_t CIRGenFunction::getOverlapForBaseInit(
return AggValueSlot::MayOverlap;
}
+/// CheckAggExprForMemSetUse - If the initializer is large and has a lot of
+/// zeros in it, emit a memset and avoid storing the individual zeros.
+static void checkAggExprForMemSetUse(AggValueSlot &slot, const Expr *e,
+ CIRGenFunction &cgf) {
+ // If the slot is already known to be zeroed, nothing to do. Don't mess with
+ // volatile stores.
+ if (slot.isZeroed() || slot.isVolatile() || !slot.getAddress().isValid())
+ return;
+
+ // C++ objects with a user-declared constructor don't need zero'ing.
+ if (cgf.getLangOpts().CPlusPlus)
----------------
andykaylor wrote:
This should have curly braces since the enclosed if uses them.
https://github.com/llvm/llvm-project/pull/244282
More information about the cfe-commits
mailing list