[llvm] r331376 - Add assertion to padding size calculation, NFC
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Wed May 2 10:20:23 PDT 2018
Author: kparzysz
Date: Wed May 2 10:20:22 2018
New Revision: 331376
URL: http://llvm.org/viewvc/llvm-project?rev=331376&view=rev
Log:
Add assertion to padding size calculation, NFC
The size of an object cannot be less than the emitted size of all the
contained elements. This would cause an overflow in padding size
calculation. Add an assert to catch this.
Patch by Suyog Sarda.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=331376&r1=331375&r2=331376&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed May 2 10:20:22 2018
@@ -2235,6 +2235,7 @@ static void emitGlobalConstantDataSequen
unsigned Size = DL.getTypeAllocSize(CDS->getType());
unsigned EmittedSize = DL.getTypeAllocSize(CDS->getType()->getElementType()) *
CDS->getNumElements();
+ assert(EmittedSize <= Size && "Size cannot be less than EmittedSize!");
if (unsigned Padding = Size - EmittedSize)
AP.OutStreamer->EmitZeros(Padding);
}
More information about the llvm-commits
mailing list