diff options
author | Adrian Prantl <aprantl@apple.com> | 2014-12-05 01:02:46 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2014-12-05 01:02:46 +0000 |
commit | ab255fcd09a6fac10e597fbd8f92fd70dd321a6d (patch) | |
tree | 37c838dfdc1bbb26efbb7eb9515980e6ed159ab6 /llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
parent | c29be67009382658bfe8b33a44630dcb52823d8a (diff) | |
download | bcm5719-llvm-ab255fcd09a6fac10e597fbd8f92fd70dd321a6d.tar.gz bcm5719-llvm-ab255fcd09a6fac10e597fbd8f92fd70dd321a6d.zip |
Cleanup: Calls to getDwarfRegNum() may actually fail, if there is
no DWARF register number mapping, or if the register was a virtual
register that was never materialized. Previously, we would just emit a
bogus location, after this patch we don't emit a location at all by
doing an early exit.
After my bugfix in r223401 today, this doesn't actually happen on any
target that I tested this with, but it's still preferable to make the
possibility of a failure explicit.
llvm-svn: 223428
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 38100bc2f4c..6901d2290e2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -746,14 +746,17 @@ void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute, bool Indirect) { DIELoc *Loc = new (DIEValueAllocator) DIELoc(); + bool validReg; if (Location.isReg() && !Indirect) - addRegisterOpPiece(*Loc, Location.getReg()); - else { - addRegisterOffset(*Loc, Location.getReg(), Location.getOffset()); - if (Indirect && !Location.isReg()) { - addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref); - } - } + validReg = addRegisterOpPiece(*Loc, Location.getReg()); + else + validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset()); + + if (!validReg) + return; + + if (!Location.isReg() && Indirect) + addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref); // Now attach the location information to the DIE. addBlock(Die, Attribute, Loc); @@ -769,25 +772,29 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die, DIELoc *Loc = new (DIEValueAllocator) DIELoc(); unsigned N = DV.getNumAddrElements(); unsigned i = 0; + bool validReg; if (Location.isReg()) { if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_plus) { assert(!DV.getVariable().isIndirect() && "double indirection not handled"); // If first address element is OpPlus then emit // DW_OP_breg + Offset instead of DW_OP_reg + Offset. - addRegisterOffset(*Loc, Location.getReg(), DV.getAddrElement(1)); + validReg = addRegisterOffset(*Loc, Location.getReg(), DV.getAddrElement(1)); i = 2; } else if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_deref) { assert(!DV.getVariable().isIndirect() && "double indirection not handled"); - addRegisterOpPiece(*Loc, Location.getReg(), - DV.getExpression().getPieceSize(), - DV.getExpression().getPieceOffset()); + validReg = addRegisterOpPiece(*Loc, Location.getReg(), + DV.getExpression().getPieceSize(), + DV.getExpression().getPieceOffset()); i = 3; } else - addRegisterOpPiece(*Loc, Location.getReg()); + validReg = addRegisterOpPiece(*Loc, Location.getReg()); } else - addRegisterOffset(*Loc, Location.getReg(), Location.getOffset()); + validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset()); + + if (!validReg) + return; for (; i < N; ++i) { uint64_t Element = DV.getAddrElement(i); |