mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
don't emit zero bit fields with Emit, fixing undefined behavior,
PR7778 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -88,7 +88,7 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
void Emit(uint32_t Val, unsigned NumBits) {
|
void Emit(uint32_t Val, unsigned NumBits) {
|
||||||
assert(NumBits <= 32 && "Invalid value size!");
|
assert(NumBits && NumBits <= 32 && "Invalid value size!");
|
||||||
assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!");
|
assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!");
|
||||||
CurValue |= Val << CurBit;
|
CurValue |= Val << CurBit;
|
||||||
if (CurBit + NumBits < 32) {
|
if (CurBit + NumBits < 32) {
|
||||||
@ -277,10 +277,12 @@ private:
|
|||||||
switch (Op.getEncoding()) {
|
switch (Op.getEncoding()) {
|
||||||
default: assert(0 && "Unknown encoding!");
|
default: assert(0 && "Unknown encoding!");
|
||||||
case BitCodeAbbrevOp::Fixed:
|
case BitCodeAbbrevOp::Fixed:
|
||||||
Emit((unsigned)V, (unsigned)Op.getEncodingData());
|
if (Op.getEncodingData())
|
||||||
|
Emit((unsigned)V, (unsigned)Op.getEncodingData());
|
||||||
break;
|
break;
|
||||||
case BitCodeAbbrevOp::VBR:
|
case BitCodeAbbrevOp::VBR:
|
||||||
EmitVBR64(V, (unsigned)Op.getEncodingData());
|
if (Op.getEncodingData())
|
||||||
|
EmitVBR64(V, (unsigned)Op.getEncodingData());
|
||||||
break;
|
break;
|
||||||
case BitCodeAbbrevOp::Char6:
|
case BitCodeAbbrevOp::Char6:
|
||||||
Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6);
|
Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6);
|
||||||
|
Reference in New Issue
Block a user