diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 19:34:23 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 19:34:23 +0000 | 
| commit | 58b69754af0cbff56b1cfce9be9392e4451f6628 (patch) | |
| tree | eacfc83d988e4b9d11114387ae7dc41243f2a363 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
| parent | 0378662f5bd3dbe8305a485b0282bceb8b52f465 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
| -rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 43 | 
1 files changed, 28 insertions, 15 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index cb7887890cda..649684adbf04 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -17,9 +17,10 @@  #include "DwarfAccelTable.h"  #include "DwarfCompileUnit.h"  #include "llvm/Constants.h" +#include "llvm/DebugInfo.h" +#include "llvm/DIBuilder.h"  #include "llvm/Module.h"  #include "llvm/Instructions.h" -#include "llvm/ADT/Triple.h"  #include "llvm/CodeGen/MachineFunction.h"  #include "llvm/CodeGen/MachineModuleInfo.h"  #include "llvm/MC/MCAsmInfo.h" @@ -32,11 +33,10 @@  #include "llvm/Target/TargetMachine.h"  #include "llvm/Target/TargetRegisterInfo.h"  #include "llvm/Target/TargetOptions.h" -#include "llvm/Analysis/DebugInfo.h" -#include "llvm/Analysis/DIBuilder.h"  #include "llvm/ADT/Statistic.h"  #include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/Triple.h"  #include "llvm/Support/CommandLine.h"  #include "llvm/Support/Debug.h"  #include "llvm/Support/ErrorHandling.h" @@ -117,7 +117,6 @@ DIType DbgVariable::getType() const {        if (getName() == DT.getName())          return (DT.getTypeDerivedFrom());      } -    return Ty;    }    return Ty;  } @@ -127,6 +126,7 @@ DIType DbgVariable::getType() const {  DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)    : Asm(A), MMI(Asm->MMI), FirstCU(0),      AbbreviationsSet(InitAbbreviationsSetSize), +    SourceIdMap(DIEValueAllocator), StringPool(DIEValueAllocator),      PrevLabel(NULL) {    NextStringPoolNumber = 0; @@ -566,7 +566,7 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {    NewCU->addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);    // DW_AT_stmt_list is a offset of line number information for this    // compile unit in debug_line section. -  if (Asm->MAI->doesDwarfRequireRelocationForSectionOffset()) +  if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())      NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,                      Asm->GetTempSymbol("section_line"));    else @@ -1310,8 +1310,9 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {                 MOE = MI->operands_end(); MOI != MOE; ++MOI) {            if (!MOI->isReg() || !MOI->isDef() || !MOI->getReg())              continue; -          for (const uint16_t *AI = TRI->getOverlaps(MOI->getReg()); -               unsigned Reg = *AI; ++AI) { +          for (MCRegAliasIterator AI(MOI->getReg(), TRI, true); +               AI.isValid(); ++AI) { +            unsigned Reg = *AI;              const MDNode *Var = LiveUserVar[Reg];              if (!Var)                continue; @@ -1381,7 +1382,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {                                         MF->getFunction()->getContext());      recordSourceLine(FnStartDL.getLine(), FnStartDL.getCol(),                       FnStartDL.getScope(MF->getFunction()->getContext()), -                     0); +                     DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0);    }  } @@ -1421,6 +1422,12 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {          DIVariable DV(Variables.getElement(i));          if (!DV || !DV.Verify() || !ProcessedVars.insert(DV))            continue; +        // Check that DbgVariable for DV wasn't created earlier, when +        // findAbstractVariable() was called for inlined instance of DV. +        LLVMContext &Ctx = DV->getContext(); +        DIVariable CleanDV = cleanseInlinedVariable(DV, Ctx); +        if (AbstractVariables.lookup(CleanDV)) +          continue;          if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))            addScopeVariable(Scope, new DbgVariable(DV, NULL));        } @@ -1623,7 +1630,7 @@ void DwarfDebug::emitDIE(DIE *Die) {        // DW_AT_range Value encodes offset in debug_range section.        DIEInteger *V = cast<DIEInteger>(Values[i]); -      if (Asm->MAI->doesDwarfUseLabelOffsetForRanges()) { +      if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) {          Asm->EmitLabelPlusOffset(DwarfDebugRangeSectionSym,                                   V->getValue(),                                   4); @@ -1636,10 +1643,14 @@ void DwarfDebug::emitDIE(DIE *Die) {        break;      }      case dwarf::DW_AT_location: { -      if (DIELabel *L = dyn_cast<DIELabel>(Values[i])) -        Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4); -      else +      if (DIELabel *L = dyn_cast<DIELabel>(Values[i])) { +        if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +          Asm->EmitLabelReference(L->getValue(), 4); +        else +          Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4); +      } else {          Values[i]->EmitValue(Asm, Form); +      }        break;      }      case dwarf::DW_AT_accessibility: { @@ -2049,9 +2060,11 @@ void DwarfDebug::emitDebugLoc() {              if (Element == DIBuilder::OpPlus) {                Asm->EmitInt8(dwarf::DW_OP_plus_uconst);                Asm->EmitULEB128(DV.getAddrElement(++i)); -            } else if (Element == DIBuilder::OpDeref) -              Asm->EmitInt8(dwarf::DW_OP_deref); -            else llvm_unreachable("unknown Opcode found in complex address"); +            } else if (Element == DIBuilder::OpDeref) { +              if (!Entry.Loc.isReg()) +                Asm->EmitInt8(dwarf::DW_OP_deref); +            } else +              llvm_unreachable("unknown Opcode found in complex address");            }          }        }  | 
