Skip to content

Commit 88a2f40

Browse files
authored
[Debug][AArch64] Do not crash on unknown subreg register sizes. (#160442)
The AArch64 zsub regs are scalable, so defined with a size of -1 (which comes through as 65535). The RegisterSize is only 128, so code to try and find overlapping regs of a z30_z31 in DwarfEmitter can crash on trying to access out of range bits in a BitVector. Hexagon and x86 also contain subregs with unknown sizes. Ideally most of these would be scalable values but in the meantime add a check that the register are small enough to overlap with the current register size, to prevent us from crashing. This fixes the issue reported on #153810.
1 parent fcf020f commit 88a2f40

File tree

2 files changed

+345
-1
lines changed

2 files changed

+345
-1
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool DwarfExpression::addMachineReg(const TargetRegisterInfo &TRI,
154154
unsigned Size = TRI.getSubRegIdxSize(Idx);
155155
unsigned Offset = TRI.getSubRegIdxOffset(Idx);
156156
Reg = TRI.getDwarfRegNum(SR, false);
157-
if (Reg < 0)
157+
if (Reg < 0 || Offset + Size > RegSize)
158158
continue;
159159

160160
// Used to build the intersection between the bits we already

0 commit comments

Comments
 (0)