Skip to content

Commit 390f287

Browse files
[CodeGen][Tablegen] Fix uninitialized var and shift overflow. (#84896)
Fix uninitialized var and shift overflow.
1 parent 2cf2bc4 commit 390f287

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

llvm/include/llvm/CodeGen/AccelTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class DebugNamesAbbrev : public FoldingSetNode {
353353
dwarf::Index Index;
354354
dwarf::Form Form;
355355
};
356-
DebugNamesAbbrev(uint32_t DieTag) : DieTag(DieTag) {}
356+
DebugNamesAbbrev(uint32_t DieTag) : DieTag(DieTag), Number(0) {}
357357
/// Add attribute encoding to an abbreviation.
358358
void addAttribute(const DebugNamesAbbrev::AttributeEncoding &Attr) {
359359
AttrVect.push_back(Attr);

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ void AppleAccelTableWriter::emit() const {
369369
DWARF5AccelTableData::DWARF5AccelTableData(const DIE &Die,
370370
const uint32_t UnitID,
371371
const bool IsTU)
372-
: OffsetVal(&Die), DieTag(Die.getTag()), IsTU(IsTU), UnitID(UnitID) {}
372+
: OffsetVal(&Die), DieTag(Die.getTag()), AbbrevNumber(0), IsTU(IsTU),
373+
UnitID(UnitID) {}
373374

374375
void Dwarf5AccelTableWriter::Header::emit(Dwarf5AccelTableWriter &Ctx) {
375376
assert(CompUnitCount > 0 && "Index must have at least one CU.");

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
934934
unsigned Shift = 0;
935935
do {
936936
OS << ", " << (unsigned)*I;
937-
Value += (*I & 0x7f) << Shift;
937+
Value += ((uint64_t)(*I & 0x7f)) << Shift;
938938
Shift += 7;
939939
} while (*I++ >= 128);
940940
if (Value > 127) {
@@ -947,7 +947,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
947947
Shift = 0;
948948
do {
949949
OS << ", " << (unsigned)*I;
950-
Value += (*I & 0x7f) << Shift;
950+
Value += ((uint64_t)(*I & 0x7f)) << Shift;
951951
Shift += 7;
952952
} while (*I++ >= 128);
953953
if (Value > 127) {

0 commit comments

Comments
 (0)