X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAsmPrinter%2FDwarfCompileUnit.cpp;h=b4dba9c59236aebbe574fd7b535e68b902d63349;hb=1b279144ecc41e788f7173892dfcc89f7ee6772a;hp=a8f867a16c880f25e116225b8abccff4d91f42c9;hpb=f49ead70985c52e9155c9677e22c5d055d5ab485;p=oota-llvm.git diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index a8f867a16c8..b4dba9c5923 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1,5 +1,5 @@ #include "DwarfCompileUnit.h" - +#include "DwarfExpression.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/GlobalValue.h" @@ -10,8 +10,8 @@ #include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Target/TargetSubtargetInfo.h" namespace llvm { @@ -295,7 +295,8 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(DISubprogram SP) { const TargetRegisterInfo *RI = Asm->TM.getSubtargetImpl()->getRegisterInfo(); MachineLocation Location(RI->getFrameRegister(*Asm->MF)); - addAddress(*SPDie, dwarf::DW_AT_frame_base, Location); + if (RI->isPhysicalRegister(Location.getReg())) + addAddress(*SPDie, dwarf::DW_AT_frame_base, Location); } // Add name to the name table, we do this here because we're guaranteed @@ -646,6 +647,8 @@ DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) { EntityDie = getOrCreateSubprogramDIE(DISubprogram(Entity)); else if (Entity.isType()) EntityDie = getOrCreateTypeDIE(DIType(Entity)); + else if (Entity.isGlobalVariable()) + EntityDie = getOrCreateGlobalVariableDIE(DIGlobalVariable(Entity)); else EntityDie = getDIE(Entity); assert(EntityDie); @@ -744,14 +747,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); @@ -765,49 +771,19 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location) { DIELoc *Loc = new (DIEValueAllocator) DIELoc(); - unsigned N = DV.getNumAddrElements(); - unsigned i = 0; - 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)); - 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()); - i = 3; - } else - addRegisterOpPiece(*Loc, Location.getReg()); - } else - addRegisterOffset(*Loc, Location.getReg(), Location.getOffset()); - - for (; i < N; ++i) { - uint64_t Element = DV.getAddrElement(i); - if (Element == dwarf::DW_OP_plus) { - addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); - addUInt(*Loc, dwarf::DW_FORM_udata, DV.getAddrElement(++i)); - - } else if (Element == dwarf::DW_OP_deref) { - if (!Location.isReg()) - addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref); - - } else if (Element == dwarf::DW_OP_piece) { - const unsigned SizeOfByte = 8; - unsigned PieceOffsetInBits = DV.getAddrElement(++i) * SizeOfByte; - unsigned PieceSizeInBits = DV.getAddrElement(++i) * SizeOfByte; - // Emit DW_OP_bit_piece Size Offset. - assert(PieceSizeInBits > 0 && "piece has zero size"); - addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_bit_piece); - addUInt(*Loc, dwarf::DW_FORM_udata, PieceSizeInBits); - addUInt(*Loc, dwarf::DW_FORM_udata, PieceOffsetInBits); - } else - llvm_unreachable("unknown DIBuilder Opcode"); + DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc); + DIExpression Expr = DV.getExpression(); + if (Location.getOffset()) { + if (DwarfExpr.AddMachineRegIndirect(Location.getReg(), + Location.getOffset())) { + DwarfExpr.AddExpression(Expr); + assert(!DV.getVariable().isIndirect() + && "double indirection not handled"); + } + } else { + if (DwarfExpr.AddMachineRegExpression(Expr, Location.getReg())) + if (DV.getVariable().isIndirect()) + DwarfExpr.EmitOp(dwarf::DW_OP_deref); } // Now attach the location information to the DIE.