[llvm] r216134 - Don't allow MCStreamer::EmitIntValue to output 0-byte integers.
Alexey Samsonov
vonosmas at gmail.com
Wed Aug 20 15:46:39 PDT 2014
Author: samsonov
Date: Wed Aug 20 17:46:38 2014
New Revision: 216134
URL: http://llvm.org/viewvc/llvm-project?rev=216134&view=rev
Log:
Don't allow MCStreamer::EmitIntValue to output 0-byte integers.
It makes no sense and can hide bugs. In particular, it lead
to left shift by 64 bits, which is an undefined behavior,
properly reported by UBSan.
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=216134&r1=216133&r2=216134&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Aug 20 17:46:38 2014
@@ -2612,7 +2612,8 @@ bool AsmParser::parseDirectiveFill() {
for (uint64_t i = 0, e = NumValues; i != e; ++i) {
getStreamer().EmitIntValue(FillExpr, NonZeroFillSize);
- getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
+ if (NonZeroFillSize < FillSize)
+ getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
}
return false;
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=216134&r1=216133&r2=216134&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Wed Aug 20 17:46:38 2014
@@ -72,7 +72,7 @@ void MCStreamer::generateCompactUnwindEn
/// EmitIntValue - Special case of EmitValue that avoids the client having to
/// pass in a MCExpr for constant integers.
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
- assert(Size <= 8 && "Invalid size");
+ assert(1 <= Size && Size <= 8 && "Invalid size");
assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
"Invalid size");
char buf[8];
More information about the llvm-commits
mailing list