================
@@ -1774,6 +1805,50 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
       }
     }
   }
+  if (ZeroInitPadding) {
+    uint64_t TotalSize = CGF.getContext().toBits(
+        Dest.getPreferredSize(CGF.getContext(), DestLV.getType()));
+    DoZeroInitPadding(BaseAddr, LastFieldBitOffset, TotalSize);
+  }
+}
+
+void AggExprEmitter::DoZeroInitPadding(const Address BaseAddr,
+                                       uint64_t StartBitOffset,
+                                       uint64_t EndBitOffset) {
+  if (StartBitOffset >= EndBitOffset)
+    return;
+
+  auto InitBytes = [&](uint64_t Start, uint64_t End) {
+    Address Addr = CGF.Builder.CreateConstGEP(BaseAddr, Start);
+    llvm::Constant *SizeVal = CGF.Builder.getInt64(End - Start);
+    CGF.Builder.CreateMemSet(Addr, CGF.Builder.getInt8(0), SizeVal, false);
+  };
+  auto InitBits = [&](uint64_t Byte, uint64_t Start, uint64_t End) {
+    Address Addr = CGF.Builder.CreateConstGEP(BaseAddr, Byte);
+    llvm::Value *Val = Builder.CreateLoad(Addr);
----------------
efriedma-quic wrote:

What's the size of the loaded integer here?  I can't find anything that 
explicitly sets it.

https://github.com/llvm/llvm-project/pull/110051
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to