Teach dwarf writer to handle complex address expression for .debug_loc entries.

This fixes clang generated blocks' variables' debug info.
Radar 9279956.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130373 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2011-04-28 02:22:40 +00:00
parent 450ed1a05b
commit c26f5447e3
9 changed files with 137 additions and 31 deletions

View File

@ -258,15 +258,22 @@ void CompileUnit::addComplexAddress(DbgVariable *&DV, DIE *Die,
unsigned Attribute,
const MachineLocation &Location) {
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
if (Location.isReg())
addRegisterOp(Block, Location.getReg());
unsigned N = DV->getNumAddrElements();
unsigned i = 0;
if (Location.isReg()) {
if (N >= 2 && DV->getAddrElement(0) == DIBuilder::OpPlus) {
// If first address element is OpPlus then emit
// DW_OP_breg + Offset instead of DW_OP_reg + Offset.
addRegisterOffset(Block, Location.getReg(), DV->getAddrElement(1));
i = 2;
} else
addRegisterOp(Block, Location.getReg());
}
else
addRegisterOffset(Block, Location.getReg(), Location.getOffset());
for (unsigned i = 0, N = DV->getNumAddrElements(); i < N; ++i) {
for (;i < N; ++i) {
uint64_t Element = DV->getAddrElement(i);
if (Element == DIBuilder::OpPlus) {
addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
addUInt(Block, 0, dwarf::DW_FORM_udata, DV->getAddrElement(++i));