diff options
author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-05-02 17:20:22 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-05-02 17:20:22 +0000 |
commit | 5e3aba8251e92a66646a9b64311cac8f4168c1ea (patch) | |
tree | 07825b22c548ba89fea34a85d2722bbdc0a89a1d /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | |
parent | 6e9f77126bc4ce4f94d55cf65b1bc569e369ef90 (diff) | |
download | bcm5719-llvm-5e3aba8251e92a66646a9b64311cac8f4168c1ea.tar.gz bcm5719-llvm-5e3aba8251e92a66646a9b64311cac8f4168c1ea.zip |
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.
llvm-svn: 331376
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index a1af6fddda3..a55f7c26a21 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2235,6 +2235,7 @@ static void emitGlobalConstantDataSequential(const DataLayout &DL, 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); } |