[clang] [clang] Only set the trailing bytes to zero when filling a partially … (PR #79502)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 31 03:23:36 PST 2024
================
@@ -1209,8 +1301,21 @@ static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D,
// If the initializer is all or mostly the same, codegen with bzero / memset
// then do a few stores afterward.
if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
- auto *I = Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0),
- SizeVal, isVolatile);
+ size_t LeadingNonNullBytes =
+ CountLeadingNonNullBytes(CGM.getDataLayout(), constant);
----------------
serge-sans-paille wrote:
I agree, what about the updated version then?
https://github.com/llvm/llvm-project/pull/79502
More information about the cfe-commits
mailing list