aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/AsmPrinter/DIE.h4
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp301
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h35
-rw-r--r--test/DebugInfo/2010-05-25-DotDebugLoc.ll239
4 files changed, 492 insertions, 87 deletions
diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h
index 9cb8314bd9..d56c094779 100644
--- a/lib/CodeGen/AsmPrinter/DIE.h
+++ b/lib/CodeGen/AsmPrinter/DIE.h
@@ -315,6 +315,10 @@ namespace llvm {
///
virtual void EmitValue(AsmPrinter *AP, unsigned Form) const;
+ /// getValue - Get MCSymbol.
+ ///
+ const MCSymbol *getValue() const { return Label; }
+
/// SizeOf - Determine size of label value in bytes.
///
virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const;
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 145bf718f9..afa0fa16bd 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -168,15 +168,18 @@ public:
///
class DbgVariable {
DIVariable Var; // Variable Descriptor.
- DIE *TheDIE;
+ DIE *TheDIE; // Variable DIE.
+ unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
public:
// AbsVar may be NULL.
- DbgVariable(DIVariable V) : Var(V), TheDIE(0) {}
+ DbgVariable(DIVariable V) : Var(V), TheDIE(0), DotDebugLocOffset(~0U) {}
// Accessors.
DIVariable getVariable() const { return Var; }
void setDIE(DIE *D) { TheDIE = D; }
DIE *getDIE() const { return TheDIE; }
+ void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
+ unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
};
//===----------------------------------------------------------------------===//
@@ -317,8 +320,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
DwarfFrameSectionSym = DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
DwarfStrSectionSym = TextSectionSym = 0;
- DwarfDebugRangeSectionSym = 0;
- FunctionBeginSym = 0;
+ DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0;
+ FunctionBeginSym = FunctionEndSym = 0;
if (TimePassesIsEnabled) {
NamedRegionTimer T(DbgTimerName, DWARFGroupName);
beginModule(M);
@@ -1441,18 +1444,18 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) {
DebugRangeSymbols.size() * Asm->getTargetData().getPointerSize());
for (SmallVector<DbgRange, 4>::const_iterator RI = Ranges.begin(),
RE = Ranges.end(); RI != RE; ++RI) {
- DebugRangeSymbols.push_back(LabelsBeforeInsn.lookup(RI->first));
- DebugRangeSymbols.push_back(LabelsAfterInsn.lookup(RI->second));
+ DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
+ DebugRangeSymbols.push_back(getLabelAfterInsn(RI->second));
}
DebugRangeSymbols.push_back(NULL);
DebugRangeSymbols.push_back(NULL);
return ScopeDIE;
}
- MCSymbol *Start = LabelsBeforeInsn.lookup(RI->first);
- MCSymbol *End = LabelsAfterInsn.lookup(RI->second);
+ const MCSymbol *Start = getLabelBeforeInsn(RI->first);
+ const MCSymbol *End = getLabelAfterInsn(RI->second);
- if (Start == 0 || End == 0) return 0;
+ if (End == 0) return 0;
assert(Start->isDefined() && "Invalid starting label for an inlined scope!");
assert(End->isDefined() && "Invalid end label for an inlined scope!");
@@ -1477,10 +1480,10 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
// For now, use first instruction range and emit low_pc/high_pc pair and
// corresponding .debug_inlined section entry for this pair.
SmallVector<DbgRange, 4>::const_iterator RI = Ranges.begin();
- MCSymbol *StartLabel = LabelsBeforeInsn.lookup(RI->first);
- MCSymbol *EndLabel = LabelsAfterInsn.lookup(RI->second);
+ const MCSymbol *StartLabel = getLabelBeforeInsn(RI->first);
+ const MCSymbol *EndLabel = getLabelAfterInsn(RI->second);
- if (StartLabel == 0 || EndLabel == 0) {
+ if (StartLabel == FunctionBeginSym || EndLabel == 0) {
assert (0 && "Unexpected Start and End labels for a inlined scope!");
return 0;
}
@@ -1573,61 +1576,76 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
addType(VariableDie, VD.getType());
}
+ if (Tag == dwarf::DW_TAG_formal_parameter && VD.getType().isArtificial())
+ addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
+
+ if (Scope->isAbstractScope()) {
+ DV->setDIE(VariableDie);
+ return VariableDie;
+ }
+
// Add variable address.
- if (!Scope->isAbstractScope()) {
- // Check if variable is described by DBG_VALUE instruction.
- DenseMap<const DbgVariable *, const MachineInstr *>::iterator DVI =
- DbgVariableToDbgInstMap.find(DV);
- if (DVI != DbgVariableToDbgInstMap.end()) {
- const MachineInstr *DVInsn = DVI->second;
- const MCSymbol *DVLabel = findVariableLabel(DV);
- bool updated = false;
- // FIXME : Handle getNumOperands != 3
- if (DVInsn->getNumOperands() == 3) {
- if (DVInsn->getOperand(0).isReg())
- updated = addRegisterAddress(VariableDie, DVLabel, DVInsn->getOperand(0));
- else if (DVInsn->getOperand(0).isImm())
- updated = addConstantValue(VariableDie, DVLabel, DVInsn->getOperand(0));
- else if (DVInsn->getOperand(0).isFPImm())
- updated = addConstantFPValue(VariableDie, DVLabel, DVInsn->getOperand(0));
- } else {
- MachineLocation Location = Asm->getDebugValueLocation(DVInsn);
- if (Location.getReg()) {
- addAddress(VariableDie, dwarf::DW_AT_location, Location);
- if (DVLabel)
- addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr,
- DVLabel);
- updated = true;
- }
- }
- if (!updated) {
- // If variableDie is not updated then DBG_VALUE instruction does not
- // have valid variable info.
- delete VariableDie;
- return NULL;
- }
- }
- else {
- MachineLocation Location;
- unsigned FrameReg;
- const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
- int FI = 0;
- if (findVariableFrameIndex(DV, &FI)) {
- int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
- Location.set(FrameReg, Offset);
-
- if (VD.hasComplexAddress())
- addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
- else if (VD.isBlockByrefVariable())
- addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
- else
- addAddress(VariableDie, dwarf::DW_AT_location, Location);
+
+ unsigned Offset = DV->getDotDebugLocOffset();
+ if (Offset != ~0U) {
+ addLabel(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_data4,
+ Asm->GetTempSymbol("debug_loc", Offset));
+ DV->setDIE(VariableDie);
+ UseDotDebugLocEntry.insert(VariableDie);
+ return VariableDie;
+ }
+
+ // Check if variable is described by a DBG_VALUE instruction.
+ DenseMap<const DbgVariable *, const MachineInstr *>::iterator DVI =
+ DbgVariableToDbgInstMap.find(DV);
+ if (DVI != DbgVariableToDbgInstMap.end()) {
+ const MachineInstr *DVInsn = DVI->second;
+ const MCSymbol *DVLabel = findVariableLabel(DV);
+ bool updated = false;
+ // FIXME : Handle getNumOperands != 3
+ if (DVInsn->getNumOperands() == 3) {
+ if (DVInsn->getOperand(0).isReg())
+ updated = addRegisterAddress(VariableDie, DVLabel, DVInsn->getOperand(0));
+ else if (DVInsn->getOperand(0).isImm())
+ updated = addConstantValue(VariableDie, DVLabel, DVInsn->getOperand(0));
+ else if (DVInsn->getOperand(0).isFPImm())
+ updated = addConstantFPValue(VariableDie, DVLabel, DVInsn->getOperand(0));
+ } else {
+ MachineLocation Location = Asm->getDebugValueLocation(DVInsn);
+ if (Location.getReg()) {
+ addAddress(VariableDie, dwarf::DW_AT_location, Location);
+ if (DVLabel)
+ addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr,
+ DVLabel);
+ updated = true;
}
}
- }
+ if (!updated) {
+ // If variableDie is not updated then DBG_VALUE instruction does not
+ // have valid variable info.
+ delete VariableDie;
+ return NULL;
+ }
+ DV->setDIE(VariableDie);
+ return VariableDie;
+ }
- if (Tag == dwarf::DW_TAG_formal_parameter && VD.getType().isArtificial())
- addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
+ // .. else use frame index, if available.
+ MachineLocation Location;
+ unsigned FrameReg;
+ const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
+ int FI = 0;
+ if (findVariableFrameIndex(DV, &FI)) {
+ int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
+ Location.set(FrameReg, Offset);
+
+ if (VD.hasComplexAddress())
+ addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
+ else if (VD.isBlockByrefVariable())
+ addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
+ else
+ addAddress(VariableDie, dwarf::DW_AT_location, Location);
+ }
DV->setDIE(VariableDie);
return VariableDie;
@@ -2113,6 +2131,24 @@ DwarfDebug::collectVariableInfoFromMMITable(const MachineFunction * MF,
}
}
+/// isDbgValueInUndefinedReg - Return true if debug value, encoded by
+/// DBG_VALUE instruction, is in undefined reg.
+static bool isDbgValueInUndefinedReg(const MachineInstr *MI) {
+ assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!");
+ if (MI->getOperand(0).isReg() && !MI->getOperand(0).getReg())
+ return true;
+ return false;
+}
+
+/// isDbgValueInDefinedReg - Return true if debug value, encoded by
+/// DBG_VALUE instruction, is in a defined reg.
+static bool isDbgValueInDefinedReg(const MachineInstr *MI) {
+ assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!");
+ if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg())
+ return true;
+ return false;
+}
+
/// collectVariableInfo - Populate DbgScope entries with variables' info.
void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
SmallPtrSet<const MDNode *, 16> Processed;
@@ -2127,24 +2163,31 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
II != IE; ++II) {
const MachineInstr *MInsn = II;
- if (!MInsn->isDebugValue())
- continue;
-
- // Ignore Undef values.
- if (MInsn->getOperand(0).isReg() && !MInsn->getOperand(0).getReg())
+ if (!MInsn->isDebugValue() || isDbgValueInUndefinedReg(MInsn))
continue;
-
DbgValues.push_back(MInsn);
}
+ // This is a collection of DBV_VALUE instructions describing same variable.
+ SmallVector<const MachineInstr *, 4> MultipleValues;
for(SmallVector<const MachineInstr *, 8>::iterator I = DbgValues.begin(),
E = DbgValues.end(); I != E; ++I) {
const MachineInstr *MInsn = *I;
-
+ MultipleValues.clear();
+ if (isDbgValueInDefinedReg(MInsn))
+ MultipleValues.push_back(MInsn);
DIVariable DV(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata());
if (Processed.count(DV) != 0)
continue;
+ for (SmallVector<const MachineInstr *, 8>::iterator MI = I+1,
+ ME = DbgValues.end(); MI != ME; ++MI) {
+ const MDNode *Var =
+ (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata();
+ if (Var == DV && isDbgValueInDefinedReg(*MI))
+ MultipleValues.push_back(*MI);
+ }
+
DbgScope *Scope = findDbgScope(MInsn);
if (!Scope && DV.getTag() == dwarf::DW_TAG_arg_variable)
Scope = CurrentFnDbgScope;
@@ -2154,16 +2197,45 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
Processed.insert(DV);
DbgVariable *RegVar = new DbgVariable(DV);
- DbgVariableToDbgInstMap[RegVar] = MInsn;
Scope->addVariable(RegVar);
if (DV.getTag() != dwarf::DW_TAG_arg_variable) {
DbgValueStartMap[MInsn] = RegVar;
- DbgVariableLabelsMap[RegVar] = LabelsBeforeInsn.lookup(MInsn);
+ DbgVariableLabelsMap[RegVar] = getLabelBeforeInsn(MInsn);
}
if (DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc())) {
DbgVariableToDbgInstMap[AbsVar] = MInsn;
VarToAbstractVarMap[RegVar] = AbsVar;
}
+ if (MultipleValues.size() <= 1) {
+ DbgVariableToDbgInstMap[RegVar] = MInsn;
+ continue;
+ }
+
+ // handle multiple DBG_VALUE instructions describing one variable.
+ RegVar->setDotDebugLocOffset(DotDebugLocEntries.size());
+ if (DotDebugLocEntries.empty())
+ DotDebugLocEntries.push_back(DotDebugLocEntry());
+ const MachineInstr *Current = MultipleValues.back();
+ MultipleValues.pop_back();
+ while (!MultipleValues.empty()) {
+ const MachineInstr *Next = MultipleValues.back();
+ MultipleValues.pop_back();
+ DbgValueStartMap[Next] = RegVar;
+ MachineLocation MLoc;
+ MLoc.set(Current->getOperand(0).getReg(), 0);
+ const MCSymbol *FLabel = getLabelBeforeInsn(Next);
+ const MCSymbol *SLabel = getLabelBeforeInsn(Current);
+ DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc));
+ Current = Next;
+ if (MultipleValues.empty()) {
+ // If Next is the last instruction then its value is valid
+ // until the end of the funtion.
+ MLoc.set(Next->getOperand(0).getReg(), 0);
+ DotDebugLocEntries.
+ push_back(DotDebugLocEntry(SLabel, FunctionEndSym, MLoc));
+ }
+ }
+ DotDebugLocEntries.push_back(DotDebugLocEntry());
}
// Collect info for variables that were optimized out.
@@ -2178,26 +2250,45 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
Scope->addVariable(new DbgVariable(DV));
}
}
+}
+
+/// getLabelBeforeInsn - Return Label preceding the instruction.
+const MCSymbol *DwarfDebug::getLabelBeforeInsn(const MachineInstr *MI) {
+ DenseMap<const MachineInstr *, MCSymbol *>::iterator I =
+ LabelsBeforeInsn.find(MI);
+ if (I == LabelsBeforeInsn.end())
+ // FunctionBeginSym always preceeds all the instruction in current function.
+ return FunctionBeginSym;
+ return I->second;
+}
+/// getLabelAfterInsn - Return Label immediately following the instruction.
+const MCSymbol *DwarfDebug::getLabelAfterInsn(const MachineInstr *MI) {
+ DenseMap<const MachineInstr *, MCSymbol *>::iterator I =
+ LabelsAfterInsn.find(MI);
+ if (I == LabelsAfterInsn.end())
+ return NULL;
+ return I->second;
}
/// beginScope - Process beginning of a scope.
void DwarfDebug::beginScope(const MachineInstr *MI) {
// Check location.
DebugLoc DL = MI->getDebugLoc();
- if (DL.isUnknown() && !UnknownLocations)
+ if (DL.isUnknown() && !UnknownLocations) {
+ if (MI->isDebugValue() && PrevLabel)
+ LabelsBeforeInsn[MI] = PrevLabel;
return;
+ }
bool LocalVar = false;
if (MI->isDebugValue()) {
assert (MI->getNumOperands() > 1 && "Invalid machine instruction!");
DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata());
if (!DV.Verify()) return;
- if (DV.getTag() != dwarf::DW_TAG_arg_variable)
+ if (DV.getTag() != dwarf::DW_TAG_arg_variable
+ && !isDbgValueInUndefinedReg(MI))
LocalVar = true;
- // Ignore Undef values.
- if (MI->getOperand(0).isReg() && !MI->getOperand(0).getReg())
- LocalVar = false;
}
MCSymbol *Label = NULL;
@@ -2224,7 +2315,7 @@ void DwarfDebug::beginScope(const MachineInstr *MI) {
// If this instruction begins a scope then note down corresponding label
// even if previous label is reused.
- if (InsnsBeginScopeSet.count(MI) != 0)
+ if (Label && (InsnsBeginScopeSet.count(MI) != 0 || MI->isDebugValue()))
LabelsBeforeInsn[MI] = Label;
}
@@ -2544,12 +2635,14 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
if (CurrentFnDbgScope) {
- collectVariableInfo(MF);
-
// Define end label for subprogram.
- Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("func_end",
- Asm->getFunctionNumber()));
+ FunctionEndSym = Asm->GetTempSymbol("func_end",
+ Asm->getFunctionNumber());
+ // Assumes in correct section after the entry point.
+ Asm->OutStreamer.EmitLabel(FunctionEndSym);
+ collectVariableInfo(MF);
+
// Get function line info.
if (!Lines.empty()) {
// Get section line info.
@@ -2790,6 +2883,9 @@ void DwarfDebug::EmitSectionLabels() {
DwarfDebugRangeSectionSym = EmitSectionSym(Asm, TLOF.getDwarfRangesSection(),
"debug_range");
+ DwarfDebugLocSectionSym = EmitSectionSym(Asm, TLOF.getDwarfLocSection(),
+ "section_debug_loc");
+
TextSectionSym = EmitSectionSym(Asm, TLOF.getTextSection(), "text_begin");
EmitSectionSym(Asm, TLOF.getDataSection());
}
@@ -2841,6 +2937,14 @@ void DwarfDebug::emitDIE(DIE *Die) {
4);
break;
}
+ case dwarf::DW_AT_location: {
+ if (UseDotDebugLocEntry.count(Die) != 0) {
+ DIELabel *L = cast<DIELabel>(Values[i]);
+ Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4);
+ } else
+ Values[i]->EmitValue(Asm, Form);
+ break;
+ }
default:
// Emit an attribute using the defined form.
Values[i]->EmitValue(Asm, Form);
@@ -3356,7 +3460,38 @@ void DwarfDebug::emitDebugStr() {
void DwarfDebug::emitDebugLoc() {
// Start the dwarf loc section.
Asm->OutStreamer.SwitchSection(
- Asm->getObjFileLowering().getDwarfLocSection());
+ Asm->getObjFileLowering().getDwarfLocSection());
+ unsigned char Size = Asm->getTargetData().getPointerSize();
+ unsigned index = 0;
+ bool needMarker = true;
+ for (SmallVector<DotDebugLocEntry, 4>::iterator I = DotDebugLocEntries.begin(),
+ E = DotDebugLocEntries.end(); I != E; ++I, ++index) {
+ DotDebugLocEntry Entry = *I;
+ if (needMarker) {
+ Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", index));
+ needMarker = false;
+ }
+ if (Entry.isEmpty()) {
+ Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0);
+ Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0);
+ needMarker = true;
+ } else {
+ Asm->OutStreamer.EmitSymbolValue(Entry.Begin, Size, 0);
+ Asm->OutStreamer.EmitSymbolValue(Entry.End, Size, 0);
+ const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
+ unsigned Reg = RI->getDwarfRegNum(Entry.Loc.getReg(), false);
+ if (Reg < 32) {
+ Asm->OutStreamer.AddComment("Loc expr size");
+ Asm->EmitInt16(1);
+ Asm->EmitInt8(dwarf::DW_OP_reg0 + Reg);
+ } else {
+ Asm->OutStreamer.AddComment("Loc expr size");
+ Asm->EmitInt16(1+MCAsmInfo::getULEB128Size(Reg));
+ Asm->EmitInt8(dwarf::DW_OP_regx);
+ Asm->EmitULEB128(Reg);
+ }
+ }
+ }
}
/// EmitDebugARanges - Emit visible names into a debug aranges section.
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 6728199c5e..781302e999 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -15,6 +15,7 @@
#define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "DIE.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
@@ -30,7 +31,6 @@ class DbgConcreteScope;
class DbgScope;
class DbgVariable;
class MachineFrameInfo;
-class MachineLocation;
class MachineModuleInfo;
class MachineOperand;
class MCAsmInfo;
@@ -181,6 +181,27 @@ class DwarfDebug {
/// DbgVariableLabelsMap - Maps DbgVariable to corresponding MCSymbol.
DenseMap<const DbgVariable *, const MCSymbol *> DbgVariableLabelsMap;
+ /// DotDebugLocEntry - This struct describes location entries emitted in
+ /// .debug_loc section.
+ typedef struct DotDebugLocEntry {
+ const MCSymbol *Begin;
+ const MCSymbol *End;
+ MachineLocation Loc;
+ DotDebugLocEntry() : Begin(0), End(0) {}
+ DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
+ MachineLocation &L) : Begin(B), End(E), Loc(L) {}
+ /// Empty entries are also used as a trigger to emit temp label. Such
+ /// labels are referenced is used to find debug_loc offset for a given DIE.
+ bool isEmpty() { return Begin == 0 && End == 0; }
+ } DotDebugLocEntry;
+
+ /// DotDebugLocEntries - Collection of DotDebugLocEntry.
+ SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
+
+ /// UseDotDebugLocEntry - DW_AT_location attributes for the DIEs in this set
+ /// idetifies corresponding .debug_loc entry offset.
+ SmallPtrSet<const DIE *, 4> UseDotDebugLocEntry;
+
/// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
/// DbgVariable, if any.
DenseMap<const DbgVariable *, const DbgVariable *> VarToAbstractVarMap;
@@ -200,7 +221,7 @@ class DwarfDebug {
/// InlineInfo - Keep track of inlined functions and their location. This
/// information is used to populate debug_inlined section.
- typedef std::pair<MCSymbol *, DIE *> InlineInfoLabels;
+ typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
SmallVector<const MDNode *, 4> InlinedSPNodes;
@@ -234,8 +255,8 @@ class DwarfDebug {
// section offsets and are created by EmitSectionLabels.
MCSymbol *DwarfFrameSectionSym, *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
-
- MCSymbol *FunctionBeginSym;
+ MCSymbol *DwarfDebugLocSectionSym;
+ MCSymbol *FunctionBeginSym, *FunctionEndSym;
private:
/// getSourceDirectoryAndFileIds - Return the directory and file ids that
@@ -600,6 +621,12 @@ public:
///
void endFunction(const MachineFunction *MF);
+ /// getLabelBeforeInsn - Return Label preceding the instruction.
+ const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
+
+ /// getLabelAfterInsn - Return Label immediately following the instruction.
+ const MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
+
/// beginScope - Process beginning of a scope.
void beginScope(const MachineInstr *MI);
diff --git a/test/DebugInfo/2010-05-25-DotDebugLoc.ll b/test/DebugInfo/2010-05-25-DotDebugLoc.ll
new file mode 100644
index 0000000000..e6a7a6c5ed
--- /dev/null
+++ b/test/DebugInfo/2010-05-25-DotDebugLoc.ll
@@ -0,0 +1,239 @@
+; RUN: llc -O2 < %s | grep debug_loc13
+; Test to check .debug_loc support. This test case emits 14 debug_loc entries.
+
+%0 = type { double }
+
+define hidden %0 @__divsc3(float %a, float %b, float %c, float %d) nounwind readnone {
+entry:
+ tail call void @llvm.dbg.value(metadata !{float %a}, i64 0, metadata !0)
+ tail call void @llvm.dbg.value(metadata !{float %b}, i64 0, metadata !11)
+ tail call void @llvm.dbg.value(metadata !{float %c}, i64 0, metadata !12)
+ tail call void @llvm.dbg.value(metadata !{float %d}, i64 0, metadata !13)
+ %0 = tail call float @fabsf(float %c) nounwind readnone, !dbg !19 ; <float> [#uses=1]
+ %1 = tail call float @fabsf(float %d) nounwind readnone, !dbg !19 ; <float> [#uses=1]
+ %2 = fcmp olt float %0, %1, !dbg !19 ; <i1> [#uses=1]
+ br i1 %2, label %bb, label %bb1, !dbg !19
+
+bb: ; preds = %entry
+ %3 = fdiv float %c, %d, !dbg !20 ; <float> [#uses=3]
+ tail call void @llvm.dbg.value(metadata !{float %3}, i64 0, metadata !16), !dbg !20
+ %4 = fmul float %3, %c, !dbg !21 ; <float> [#uses=1]
+ %5 = fadd float %4, %d, !dbg !21 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %5}, i64 0, metadata !14), !dbg !21
+ %6 = fmul float %3, %a, !dbg !22 ; <float> [#uses=1]
+ %7 = fadd float %6, %b, !dbg !22 ; <float> [#uses=1]
+ %8 = fdiv float %7, %5, !dbg !22 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %8}, i64 0, metadata !17), !dbg !22
+ %9 = fmul float %3, %b, !dbg !23 ; <float> [#uses=1]
+ %10 = fsub float %9, %a, !dbg !23 ; <float> [#uses=1]
+ %11 = fdiv float %10, %5, !dbg !23 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %11}, i64 0, metadata !18), !dbg !23
+ br label %bb2, !dbg !23
+
+bb1: ; preds = %entry
+ %12 = fdiv float %d, %c, !dbg !24 ; <float> [#uses=3]
+ tail call void @llvm.dbg.value(metadata !{float %12}, i64 0, metadata !16), !dbg !24
+ %13 = fmul float %12, %d, !dbg !25 ; <float> [#uses=1]
+ %14 = fadd float %13, %c, !dbg !25 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %14}, i64 0, metadata !14), !dbg !25
+ %15 = fmul float %12, %b, !dbg !26 ; <float> [#uses=1]
+ %16 = fadd float %15, %a, !dbg !26 ; <float> [#uses=1]
+ %17 = fdiv float %16, %14, !dbg !26 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %17}, i64 0, metadata !17), !dbg !26
+ %18 = fmul float %12, %a, !dbg !27 ; <float> [#uses=1]
+ %19 = fsub float %b, %18, !dbg !27 ; <float> [#uses=1]
+ %20 = fdiv float %19, %14, !dbg !27 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %20}, i64 0, metadata !18), !dbg !27
+ br label %bb2, !dbg !27
+
+bb2: ; preds = %bb1, %bb
+ %y.0 = phi float [ %11, %bb ], [ %20, %bb1 ] ; <float> [#uses=5]
+ %x.0 = phi float [ %8, %bb ], [ %17, %bb1 ] ; <float> [#uses=5]
+ %21 = fcmp uno float %x.0, 0.000000e+00, !dbg !28 ; <i1> [#uses=1]
+ %22 = fcmp uno float %y.0, 0.000000e+00, !dbg !28 ; <i1> [#uses=1]
+ %or.cond = and i1 %21, %22 ; <i1> [#uses=1]
+ br i1 %or.cond, label %bb4, label %bb46, !dbg !28
+
+bb4: ; preds = %bb2
+ %23 = fcmp une float %c, 0.000000e+00, !dbg !29 ; <i1> [#uses=1]
+ %24 = fcmp une float %d, 0.000000e+00, !dbg !29 ; <i1> [#uses=1]
+ %or.cond93 = or i1 %23, %24 ; <i1> [#uses=1]
+ br i1 %or.cond93, label %bb9, label %bb6, !dbg !29
+
+bb6: ; preds = %bb4
+ %25 = fcmp uno float %a, 0.000000e+00, !dbg !29 ; <i1> [#uses=1]
+ %26 = fcmp uno float %b, 0.000000e+00, !dbg !29 ; <i1> [#uses=1]
+ %or.cond94 = and i1 %25, %26 ; <i1> [#uses=1]
+ br i1 %or.cond94, label %bb9, label %bb8, !dbg !29
+
+bb8: ; preds = %bb6
+ %27 = tail call float @copysignf(float 0x7FF0000000000000, float %c) nounwind readnone, !dbg !30 ; <float> [#uses=2]
+ %28 = fmul float %27, %a, !dbg !30 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %28}, i64 0, metadata !17), !dbg !30
+ %29 = fmul float %27, %b, !dbg !31 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %29}, i64 0, metadata !18), !dbg !31
+ br label %bb46, !dbg !31
+
+bb9: ; preds = %bb6, %bb4
+ %30 = fcmp ord float %a, 0.000000e+00 ; <i1> [#uses=1]
+ %31 = fsub float %a, %a, !dbg !32 ; <float> [#uses=3]
+ %32 = fcmp uno float %31, 0.000000e+00 ; <i1> [#uses=1]
+ %33 = and i1 %30, %32, !dbg !32 ; <i1> [#uses=2]
+ br i1 %33, label %bb14, label %bb11, !dbg !32
+
+bb11: ; preds = %bb9
+ %34 = fcmp ord float %b, 0.000000e+00 ; <i1> [#uses=1]
+ %35 = fsub float %b, %b, !dbg !32 ; <float> [#uses=1]
+ %36 = fcmp uno float %35, 0.000000e+00 ; <i1> [#uses=1]
+ %37 = and i1 %34, %36, !dbg !32 ; <i1> [#uses=1]
+ br i1 %37, label %bb14, label %bb27, !dbg !32
+
+bb14: ; preds = %bb11, %bb9
+ %38 = fsub float %c, %c, !dbg !32 ; <float> [#uses=1]
+ %39 = fcmp ord float %38, 0.000000e+00 ; <i1> [#uses=1]
+ br i1 %39, label %bb15, label %bb27, !dbg !32
+
+bb15: ; preds = %bb14
+ %40 = fsub float %d, %d, !dbg !32 ; <float> [#uses=1]
+ %41 = fcmp ord float %40, 0.000000e+00 ; <i1> [#uses=1]
+ br i1 %41, label %bb16, label %bb27, !dbg !32
+
+bb16: ; preds = %bb15
+ %iftmp.0.0 = select i1 %33, float 1.000000e+00, float 0.000000e+00 ; <float> [#uses=1]
+ %42 = tail call float @copysignf(float %iftmp.0.0, float %a) nounwind readnone, !dbg !33 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %42}, i64 0, metadata !0), !dbg !33
+ %43 = fcmp ord float %b, 0.000000e+00 ; <i1> [#uses=1]
+ %44 = fsub float %b, %b, !dbg !34 ; <float> [#uses=1]
+ %45 = fcmp uno float %44, 0.000000e+00 ; <i1> [#uses=1]
+ %46 = and i1 %43, %45, !dbg !34 ; <i1> [#uses=1]
+ %iftmp.1.0 = select i1 %46, float 1.000000e+00, float 0.000000e+00 ; <float> [#uses=1]
+ %47 = tail call float @copysignf(float %iftmp.1.0, float %b) nounwind readnone, !dbg !34 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %47}, i64 0, metadata !11), !dbg !34
+ %48 = fmul float %42, %c, !dbg !35 ; <float> [#uses=1]
+ %49 = fmul float %47, %d, !dbg !35 ; <float> [#uses=1]
+ %50 = fadd float %48, %49, !dbg !35 ; <float> [#uses=1]
+ %51 = fmul float %50, 0x7FF0000000000000, !dbg !35 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %51}, i64 0, metadata !17), !dbg !35
+ %52 = fmul float %47, %c, !dbg !36 ; <float> [#uses=1]
+ %53 = fmul float %42, %d, !dbg !36 ; <float> [#uses=1]
+ %54 = fsub float %52, %53, !dbg !36 ; <float> [#uses=1]
+ %55 = fmul float %54, 0x7FF0000000000000, !dbg !36 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %55}, i64 0, metadata !18), !dbg !36
+ br label %bb46, !dbg !36
+
+bb27: ; preds = %bb15, %bb14, %bb11
+ %56 = fcmp ord float %c, 0.000000e+00 ; <i1> [#uses=1]
+ %57 = fsub float %c, %c, !dbg !37 ; <float> [#uses=1]
+ %58 = fcmp uno float %57, 0.000000e+00 ; <i1> [#uses=1]
+ %59 = and i1 %56, %58, !dbg !37 ; <i1> [#uses=2]
+ br i1 %59, label %bb33, label %bb30, !dbg !37
+
+bb30: ; preds = %bb27
+ %60 = fcmp ord float %d, 0.000000e+00 ; <i1> [#uses=1]
+ %61 = fsub float %d, %d, !dbg !37 ; <float> [#uses=1]
+ %62 = fcmp uno float %61, 0.000000e+00 ; <i1> [#uses=1]
+ %63 = and i1 %60, %62, !dbg !37 ; <i1> [#uses=1]
+ %64 = fcmp ord float %31, 0.000000e+00 ; <i1> [#uses=1]
+ %or.cond95 = and i1 %63, %64 ; <i1> [#uses=1]
+ br i1 %or.cond95, label %bb34, label %bb46, !dbg !37
+
+bb33: ; preds = %bb27
+ %.old = fcmp ord float %31, 0.000000e+00 ; <i1> [#uses=1]
+ br i1 %.old, label %bb34, label %bb46, !dbg !37
+
+bb34: ; preds = %bb33, %bb30
+ %65 = fsub float %b, %b, !dbg !37 ; <float> [#uses=1]
+ %66 = fcmp ord float %65, 0.000000e+00 ; <i1> [#uses=1]
+ br i1 %66, label %bb35, label %bb46, !dbg !37
+
+bb35: ; preds = %bb34
+ %iftmp.2.0 = select i1 %59, float 1.000000e+00, float 0.000000e+00 ; <float> [#uses=1]
+ %67 = tail call float @copysignf(float %iftmp.2.0, float %c) nounwind readnone, !dbg !38 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %67}, i64 0, metadata !12), !dbg !38
+ %68 = fcmp ord float %d, 0.000000e+00 ; <i1> [#uses=1]
+ %69 = fsub float %d, %d, !dbg !39 ; <float> [#uses=1]
+ %70 = fcmp uno float %69, 0.000000e+00 ; <i1> [#uses=1]
+ %71 = and i1 %68, %70, !dbg !39 ; <i1> [#uses=1]
+ %iftmp.3.0 = select i1 %71, float 1.000000e+00, float 0.000000e+00 ; <float> [#uses=1]
+ %72 = tail call float @copysignf(float %iftmp.3.0, float %d) nounwind readnone, !dbg !39 ; <float> [#uses=2]
+ tail call void @llvm.dbg.value(metadata !{float %72}, i64 0, metadata !13), !dbg !39
+ %73 = fmul float %67, %a, !dbg !40 ; <float> [#uses=1]
+ %74 = fmul float %72, %b, !dbg !40 ; <float> [#uses=1]
+ %75 = fadd float %73, %74, !dbg !40 ; <float> [#uses=1]
+ %76 = fmul float %75, 0.000000e+00, !dbg !40 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %76}, i64 0, metadata !17), !dbg !40
+ %77 = fmul float %67, %b, !dbg !41 ; <float> [#uses=1]
+ %78 = fmul float %72, %a, !dbg !41 ; <float> [#uses=1]
+ %79 = fsub float %77, %78, !dbg !41 ; <float> [#uses=1]
+ %80 = fmul float %79, 0.000000e+00, !dbg !41 ; <float> [#uses=1]
+ tail call void @llvm.dbg.value(metadata !{float %80}, i64 0, metadata !18), !dbg !41
+ br label %bb46, !dbg !41
+
+bb46: ; preds = %bb35, %bb34, %bb33, %bb30, %bb16, %bb8, %bb2
+ %y.1 = phi float [ %80, %bb35 ], [ %y.0, %bb34 ], [ %y.0, %bb33 ], [ %y.0, %bb30 ], [ %55, %bb16 ], [ %29, %bb8 ], [ %y.0, %bb2 ] ; <float> [#uses=2]
+ %x.1 = phi float [ %76, %bb35 ], [ %x.0, %bb34 ], [ %x.0, %bb33 ], [ %x.0, %bb30 ], [ %51, %bb16 ], [ %28, %bb8 ], [ %x.0, %bb2 ] ; <float> [#uses=1]
+ %81 = fmul float %y.1, 0.000000e+00, !dbg !42 ; <float> [#uses=1]
+ %82 = fadd float %y.1, 0.000000e+00, !dbg !42 ; <float> [#uses=1]
+ %tmpr = fadd float %x.1, %81, !dbg !42 ; <float> [#uses=1]
+ %tmp89 = bitcast float %tmpr to i32 ; <i32> [#uses=1]
+ %tmp90 = zext i32 %tmp89 to i64 ; <i64> [#uses=1]
+ %tmp85 = bitcast float %82 to i32 ; <i32> [#uses=1]
+ %tmp86 = zext i32 %tmp85 to i64 ; <i64> [#uses=1]
+ %tmp87 = shl i64 %tmp86, 32 ; <i64> [#uses=1]
+ %ins = or i64 %tmp90, %tmp87 ; <i64> [#uses=1]
+ %tmp84 = bitcast i64 %ins to double ; <double> [#uses=1]
+ %mrv75 = insertvalue %0 undef, double %tmp84, 0, !dbg !42 ; <%0> [#uses=1]
+ ret %0 %mrv75, !dbg !42
+}
+
+declare float @fabsf(float)
+
+declare float @copysignf(float, float) nounwind readnone
+
+declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
+
+!llvm.dbg.lv = !{!0, !11, !12, !13, !14, !16, !17, !18}
+
+!0 = metadata !{i32 524545, metadata !1, metadata !"a", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
+!1 = metadata !{i32 524334, i32 0, metadata !2, metadata !"__divsc3", metadata !"__divsc3", metadata !"__divsc3", metadata !2, i32 1922, metadata !4, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
+!2 = metadata !{i32 524329, metadata !"libgcc2.c", metadata !"/Users/yash/clean/LG.D/gcc/../../llvmgcc/gcc", metadata !3} ; [ DW_TAG_file_type ]
+!3 = metadata !{i32 524305, i32 0, i32 1, metadata !"libgcc2.c", metadata !"/Users/yash/clean/LG.D/gcc/../../llvmgcc/gcc", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
+!4 = metadata !{i32 524309, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !5, i32 0, null} ; [ DW_TAG_subroutine_type ]
+!5 = metadata !{metadata !6, metadata !9, metadata !9, metadata !9, metadata !9}
+!6 = metadata !{i32 524310, metadata !7, metadata !"SCtype", metadata !7, i32 170, i64 0, i64 0, i64 0, i32 0, metadata !8} ; [ DW_TAG_typedef ]
+!7 = metadata !{i32 524329, metadata !"libgcc2.h", metadata !"/Users/yash/clean/LG.D/gcc/../../llvmgcc/gcc", metadata !3} ; [ DW_TAG_file_type ]
+!8 = metadata !{i32 524324, metadata !2, metadata !"complex float", metadata !2, i32 0, i64 64, i64 32, i64 0, i32 0, i32 3} ; [ DW_TAG_base_type ]
+!9 = metadata !{i32 524310, metadata !7, metadata !"SFtype", metadata !7, i32 167, i64 0, i64 0, i64 0, i32 0, metadata !10} ; [ DW_TAG_typedef ]
+!10 = metadata !{i32 524324, metadata !2, metadata !"float", metadata !2, i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ]
+!11 = metadata !{i32 524545, metadata !1, metadata !"b", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
+!12 = metadata !{i32 524545, metadata !1, metadata !"c", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
+!13 = metadata !{i32 524545, metadata !1, metadata !"d", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
+!14 = metadata !{i32 524544, metadata !15, metadata !"denom", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
+!15 = metadata !{i32 524299, metadata !1, i32 1922, i32 0} ; [ DW_TAG_lexical_block ]
+!16 = metadata !{i32 524544, metadata !15, metadata !"ratio", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
+!17 = metadata !{i32 524544, metadata !15, metadata !"x", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
+!18 = metadata !{i32 524544, metadata !15, metadata !"y", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
+!19 = metadata !{i32 1929, i32 0, metadata !15, null}
+!20 = metadata !{i32 1931, i32 0, metadata !15, null}
+!21 = metadata !{i32 1932, i32 0, metadata !15, null}
+!22 = metadata !{i32 1933, i32 0, metadata !15, null}
+!23 = metadata !{i32 1934, i32 0, metadata !15, null}
+!24 = metadata !{i32 1938, i32 0, metadata !15, null}
+!25 = metadata !{i32 1939, i32 0, metadata !15, null}
+!26 = metadata !{i32 1940, i32 0, metadata !15, null}
+!27 = metadata !{i32 1941, i32 0, metadata !15, null}
+!28 = metadata !{i32 1946, i32 0, metadata !15, null}
+!29 = metadata !{i32 1948, i32 0, metadata !15, null}
+!30 = metadata !{i32 1950, i32 0, metadata !15, null}
+!31 = metadata !{i32 1951, i32 0, metadata !15, null}
+!32 = metadata !{i32 1953, i32 0, metadata !15, null}
+!33 = metadata !{i32 1955, i32 0, metadata !15, null}
+!34 = metadata !{i32 1956, i32 0, metadata !15, null}
+!35 = metadata !{i32 1957, i32 0, metadata !15, null}
+!36 = metadata !{i32 1958, i32 0, metadata !15, null}
+!37 = metadata !{i32 1960, i32 0, metadata !15, null}
+!38 = metadata !{i32 1962, i32 0, metadata !15, null}
+!39 = metadata !{i32 1963, i32 0, metadata !15, null}
+!40 = metadata !{i32 1964, i32 0, metadata !15, null}
+!41 = metadata !{i32 1965, i32 0, metadata !15, null}
+!42 = metadata !{i32 1969, i32 0, metadata !15, null}