llvm.org GIT mirror llvm / c3f5f78
First cut at supporting .debug_loc section. This is used to track variable information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104649 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 10 years ago
4 changed file(s) with 497 addition(s) and 92 deletion(s). Raw diff Collapse all Expand all
314314 ///
315315 virtual void EmitValue(AsmPrinter *AP, unsigned Form) const;
316316
317 /// getValue - Get MCSymbol.
318 ///
319 const MCSymbol *getValue() const { return Label; }
320
317321 /// SizeOf - Determine size of label value in bytes.
318322 ///
319323 virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const;
167167 ///
168168 class DbgVariable {
169169 DIVariable Var; // Variable Descriptor.
170 DIE *TheDIE;
170 DIE *TheDIE; // Variable DIE.
171 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
171172 public:
172173 // AbsVar may be NULL.
173 DbgVariable(DIVariable V) : Var(V), TheDIE(0) {}
174 DbgVariable(DIVariable V) : Var(V), TheDIE(0), DotDebugLocOffset(~0U) {}
174175
175176 // Accessors.
176177 DIVariable getVariable() const { return Var; }
177178 void setDIE(DIE *D) { TheDIE = D; }
178179 DIE *getDIE() const { return TheDIE; }
180 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
181 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
179182 };
180183
181184 //===----------------------------------------------------------------------===//
316319
317320 DwarfFrameSectionSym = DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
318321 DwarfStrSectionSym = TextSectionSym = 0;
319 DwarfDebugRangeSectionSym = 0;
320 FunctionBeginSym = 0;
322 DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0;
323 FunctionBeginSym = FunctionEndSym = 0;
321324 if (TimePassesIsEnabled) {
322325 NamedRegionTimer T(DbgTimerName, DWARFGroupName);
323326 beginModule(M);
14401443 DebugRangeSymbols.size() * Asm->getTargetData().getPointerSize());
14411444 for (SmallVector::const_iterator RI = Ranges.begin(),
14421445 RE = Ranges.end(); RI != RE; ++RI) {
1443 DebugRangeSymbols.push_back(LabelsBeforeInsn.lookup(RI->first));
1444 DebugRangeSymbols.push_back(LabelsAfterInsn.lookup(RI->second));
1446 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
1447 DebugRangeSymbols.push_back(getLabelAfterInsn(RI->second));
14451448 }
14461449 DebugRangeSymbols.push_back(NULL);
14471450 DebugRangeSymbols.push_back(NULL);
14481451 return ScopeDIE;
14491452 }
14501453
1451 MCSymbol *Start = LabelsBeforeInsn.lookup(RI->first);
1452 MCSymbol *End = LabelsAfterInsn.lookup(RI->second);
1453
1454 if (Start == 0 || End == 0) return 0;
1454 const MCSymbol *Start = getLabelBeforeInsn(RI->first);
1455 const MCSymbol *End = getLabelAfterInsn(RI->second);
1456
1457 if (End == 0) return 0;
14551458
14561459 assert(Start->isDefined() && "Invalid starting label for an inlined scope!");
14571460 assert(End->isDefined() && "Invalid end label for an inlined scope!");
14761479 // For now, use first instruction range and emit low_pc/high_pc pair and
14771480 // corresponding .debug_inlined section entry for this pair.
14781481 SmallVector::const_iterator RI = Ranges.begin();
1479 MCSymbol *StartLabel = LabelsBeforeInsn.lookup(RI->first);
1480 MCSymbol *EndLabel = LabelsAfterInsn.lookup(RI->second);
1481
1482 if (StartLabel == 0 || EndLabel == 0) {
1482 const MCSymbol *StartLabel = getLabelBeforeInsn(RI->first);
1483 const MCSymbol *EndLabel = getLabelAfterInsn(RI->second);
1484
1485 if (StartLabel == FunctionBeginSym || EndLabel == 0) {
14831486 assert (0 && "Unexpected Start and End labels for a inlined scope!");
14841487 return 0;
14851488 }
15721575 addType(VariableDie, VD.getType());
15731576 }
15741577
1575 // Add variable address.
1576 if (!Scope->isAbstractScope()) {
1577 // Check if variable is described by DBG_VALUE instruction.
1578 DenseMap::iterator DVI =
1579 DbgVariableToDbgInstMap.find(DV);
1580 if (DVI != DbgVariableToDbgInstMap.end()) {
1581 const MachineInstr *DVInsn = DVI->second;
1582 const MCSymbol *DVLabel = findVariableLabel(DV);
1583 bool updated = false;
1584 // FIXME : Handle getNumOperands != 3
1585 if (DVInsn->getNumOperands() == 3) {
1586 if (DVInsn->getOperand(0).isReg())
1587 updated = addRegisterAddress(VariableDie, DVLabel, DVInsn->getOperand(0));
1588 else if (DVInsn->getOperand(0).isImm())
1589 updated = addConstantValue(VariableDie, DVLabel, DVInsn->getOperand(0));
1590 else if (DVInsn->getOperand(0).isFPImm())
1591 updated = addConstantFPValue(VariableDie, DVLabel, DVInsn->getOperand(0));
1592 } else {
1593 MachineLocation Location = Asm->getDebugValueLocation(DVInsn);
1594 if (Location.getReg()) {
1595 addAddress(VariableDie, dwarf::DW_AT_location, Location);
1596 if (DVLabel)
1597 addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr,
1598 DVLabel);
1599 updated = true;
1600 }
1601 }
1602 if (!updated) {
1603 // If variableDie is not updated then DBG_VALUE instruction does not
1604 // have valid variable info.
1605 delete VariableDie;
1606 return NULL;
1607 }
1608 }
1609 else {
1610 MachineLocation Location;
1611 unsigned FrameReg;
1612 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
1613 int FI = 0;
1614 if (findVariableFrameIndex(DV, &FI)) {
1615 int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
1616 Location.set(FrameReg, Offset);
1617
1618 if (VD.hasComplexAddress())
1619 addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
1620 else if (VD.isBlockByrefVariable())
1621 addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
1622 else
1623 addAddress(VariableDie, dwarf::DW_AT_location, Location);
1624 }
1625 }
1626 }
1627
16281578 if (Tag == dwarf::DW_TAG_formal_parameter && VD.getType().isArtificial())
16291579 addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
1580
1581 if (Scope->isAbstractScope()) {
1582 DV->setDIE(VariableDie);
1583 return VariableDie;
1584 }
1585
1586 // Add variable address.
1587
1588 unsigned Offset = DV->getDotDebugLocOffset();
1589 if (Offset != ~0U) {
1590 addLabel(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_data4,
1591 Asm->GetTempSymbol("debug_loc", Offset));
1592 DV->setDIE(VariableDie);
1593 UseDotDebugLocEntry.insert(VariableDie);
1594 return VariableDie;
1595 }
1596
1597 // Check if variable is described by a DBG_VALUE instruction.
1598 DenseMap::iterator DVI =
1599 DbgVariableToDbgInstMap.find(DV);
1600 if (DVI != DbgVariableToDbgInstMap.end()) {
1601 const MachineInstr *DVInsn = DVI->second;
1602 const MCSymbol *DVLabel = findVariableLabel(DV);
1603 bool updated = false;
1604 // FIXME : Handle getNumOperands != 3
1605 if (DVInsn->getNumOperands() == 3) {
1606 if (DVInsn->getOperand(0).isReg())
1607 updated = addRegisterAddress(VariableDie, DVLabel, DVInsn->getOperand(0));
1608 else if (DVInsn->getOperand(0).isImm())
1609 updated = addConstantValue(VariableDie, DVLabel, DVInsn->getOperand(0));
1610 else if (DVInsn->getOperand(0).isFPImm())
1611 updated = addConstantFPValue(VariableDie, DVLabel, DVInsn->getOperand(0));
1612 } else {
1613 MachineLocation Location = Asm->getDebugValueLocation(DVInsn);
1614 if (Location.getReg()) {
1615 addAddress(VariableDie, dwarf::DW_AT_location, Location);
1616 if (DVLabel)
1617 addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr,
1618 DVLabel);
1619 updated = true;
1620 }
1621 }
1622 if (!updated) {
1623 // If variableDie is not updated then DBG_VALUE instruction does not
1624 // have valid variable info.
1625 delete VariableDie;
1626 return NULL;
1627 }
1628 DV->setDIE(VariableDie);
1629 return VariableDie;
1630 }
1631
1632 // .. else use frame index, if available.
1633 MachineLocation Location;
1634 unsigned FrameReg;
1635 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
1636 int FI = 0;
1637 if (findVariableFrameIndex(DV, &FI)) {
1638 int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
1639 Location.set(FrameReg, Offset);
1640
1641 if (VD.hasComplexAddress())
1642 addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
1643 else if (VD.isBlockByrefVariable())
1644 addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
1645 else
1646 addAddress(VariableDie, dwarf::DW_AT_location, Location);
1647 }
16301648 DV->setDIE(VariableDie);
16311649 return VariableDie;
16321650
21122130 }
21132131 }
21142132
2133 /// isDbgValueInUndefinedReg - Return true if debug value, encoded by
2134 /// DBG_VALUE instruction, is in undefined reg.
2135 static bool isDbgValueInUndefinedReg(const MachineInstr *MI) {
2136 assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!");
2137 if (MI->getOperand(0).isReg() && !MI->getOperand(0).getReg())
2138 return true;
2139 return false;
2140 }
2141
2142 /// isDbgValueInDefinedReg - Return true if debug value, encoded by
2143 /// DBG_VALUE instruction, is in a defined reg.
2144 static bool isDbgValueInDefinedReg(const MachineInstr *MI) {
2145 assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!");
2146 if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg())
2147 return true;
2148 return false;
2149 }
2150
21152151 /// collectVariableInfo - Populate DbgScope entries with variables' info.
21162152 void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
21172153 SmallPtrSet Processed;
21262162 for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
21272163 II != IE; ++II) {
21282164 const MachineInstr *MInsn = II;
2129 if (!MInsn->isDebugValue())
2165 if (!MInsn->isDebugValue() || isDbgValueInUndefinedReg(MInsn))
21302166 continue;
2131
2132 // Ignore Undef values.
2133 if (MInsn->getOperand(0).isReg() && !MInsn->getOperand(0).getReg())
2134 continue;
2135
21362167 DbgValues.push_back(MInsn);
21372168 }
21382169
2170 // This is a collection of DBV_VALUE instructions describing same variable.
2171 SmallVector MultipleValues;
21392172 for(SmallVector::iterator I = DbgValues.begin(),
21402173 E = DbgValues.end(); I != E; ++I) {
21412174 const MachineInstr *MInsn = *I;
2142
2175 MultipleValues.clear();
2176 if (isDbgValueInDefinedReg(MInsn))
2177 MultipleValues.push_back(MInsn);
21432178 DIVariable DV(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata());
21442179 if (Processed.count(DV) != 0)
21452180 continue;
2181
2182 for (SmallVector::iterator MI = I+1,
2183 ME = DbgValues.end(); MI != ME; ++MI) {
2184 const MDNode *Var =
2185 (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata();
2186 if (Var == DV && isDbgValueInDefinedReg(*MI))
2187 MultipleValues.push_back(*MI);
2188 }
21462189
21472190 DbgScope *Scope = findDbgScope(MInsn);
21482191 if (!Scope && DV.getTag() == dwarf::DW_TAG_arg_variable)
21532196
21542197 Processed.insert(DV);
21552198 DbgVariable *RegVar = new DbgVariable(DV);
2156 DbgVariableToDbgInstMap[RegVar] = MInsn;
21572199 Scope->addVariable(RegVar);
21582200 if (DV.getTag() != dwarf::DW_TAG_arg_variable) {
21592201 DbgValueStartMap[MInsn] = RegVar;
2160 DbgVariableLabelsMap[RegVar] = LabelsBeforeInsn.lookup(MInsn);
2202 DbgVariableLabelsMap[RegVar] = getLabelBeforeInsn(MInsn);
21612203 }
21622204 if (DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc())) {
21632205 DbgVariableToDbgInstMap[AbsVar] = MInsn;
21642206 VarToAbstractVarMap[RegVar] = AbsVar;
21652207 }
2208 if (MultipleValues.size() <= 1) {
2209 DbgVariableToDbgInstMap[RegVar] = MInsn;
2210 continue;
2211 }
2212
2213 // handle multiple DBG_VALUE instructions describing one variable.
2214 RegVar->setDotDebugLocOffset(DotDebugLocEntries.size());
2215 if (DotDebugLocEntries.empty())
2216 DotDebugLocEntries.push_back(DotDebugLocEntry());
2217 const MachineInstr *Current = MultipleValues.back();
2218 MultipleValues.pop_back();
2219 while (!MultipleValues.empty()) {
2220 const MachineInstr *Next = MultipleValues.back();
2221 MultipleValues.pop_back();
2222 DbgValueStartMap[Next] = RegVar;
2223 MachineLocation MLoc;
2224 MLoc.set(Current->getOperand(0).getReg(), 0);
2225 const MCSymbol *FLabel = getLabelBeforeInsn(Next);
2226 const MCSymbol *SLabel = getLabelBeforeInsn(Current);
2227 DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc));
2228 Current = Next;
2229 if (MultipleValues.empty()) {
2230 // If Next is the last instruction then its value is valid
2231 // until the end of the funtion.
2232 MLoc.set(Next->getOperand(0).getReg(), 0);
2233 DotDebugLocEntries.
2234 push_back(DotDebugLocEntry(SLabel, FunctionEndSym, MLoc));
2235 }
2236 }
2237 DotDebugLocEntries.push_back(DotDebugLocEntry());
21662238 }
21672239
21682240 // Collect info for variables that were optimized out.
21772249 Scope->addVariable(new DbgVariable(DV));
21782250 }
21792251 }
2180
2252 }
2253
2254 /// getLabelBeforeInsn - Return Label preceding the instruction.
2255 const MCSymbol *DwarfDebug::getLabelBeforeInsn(const MachineInstr *MI) {
2256 DenseMap::iterator I =
2257 LabelsBeforeInsn.find(MI);
2258 if (I == LabelsBeforeInsn.end())
2259 // FunctionBeginSym always preceeds all the instruction in current function.
2260 return FunctionBeginSym;
2261 return I->second;
2262 }
2263
2264 /// getLabelAfterInsn - Return Label immediately following the instruction.
2265 const MCSymbol *DwarfDebug::getLabelAfterInsn(const MachineInstr *MI) {
2266 DenseMap::iterator I =
2267 LabelsAfterInsn.find(MI);
2268 if (I == LabelsAfterInsn.end())
2269 return NULL;
2270 return I->second;
21812271 }
21822272
21832273 /// beginScope - Process beginning of a scope.
21842274 void DwarfDebug::beginScope(const MachineInstr *MI) {
21852275 // Check location.
21862276 DebugLoc DL = MI->getDebugLoc();
2187 if (DL.isUnknown() && !UnknownLocations)
2277 if (DL.isUnknown() && !UnknownLocations) {
2278 if (MI->isDebugValue() && PrevLabel)
2279 LabelsBeforeInsn[MI] = PrevLabel;
21882280 return;
2281 }
21892282
21902283 bool LocalVar = false;
21912284 if (MI->isDebugValue()) {
21922285 assert (MI->getNumOperands() > 1 && "Invalid machine instruction!");
21932286 DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata());
21942287 if (!DV.Verify()) return;
2195 if (DV.getTag() != dwarf::DW_TAG_arg_variable)
2288 if (DV.getTag() != dwarf::DW_TAG_arg_variable
2289 && !isDbgValueInUndefinedReg(MI))
21962290 LocalVar = true;
2197 // Ignore Undef values.
2198 if (MI->getOperand(0).isReg() && !MI->getOperand(0).getReg())
2199 LocalVar = false;
22002291 }
22012292
22022293 MCSymbol *Label = NULL;
22232314
22242315 // If this instruction begins a scope then note down corresponding label
22252316 // even if previous label is reused.
2226 if (InsnsBeginScopeSet.count(MI) != 0)
2317 if (Label && (InsnsBeginScopeSet.count(MI) != 0 || MI->isDebugValue()))
22272318 LabelsBeforeInsn[MI] = Label;
22282319 }
22292320
25432634
25442635 if (CurrentFnDbgScope) {
25452636
2637 // Define end label for subprogram.
2638 FunctionEndSym = Asm->GetTempSymbol("func_end",
2639 Asm->getFunctionNumber());
2640 // Assumes in correct section after the entry point.
2641 Asm->OutStreamer.EmitLabel(FunctionEndSym);
2642
25462643 collectVariableInfo(MF);
25472644
2548 // Define end label for subprogram.
2549 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("func_end",
2550 Asm->getFunctionNumber()));
2551
25522645 // Get function line info.
25532646 if (!Lines.empty()) {
25542647 // Get section line info.
27892882 DwarfDebugRangeSectionSym = EmitSectionSym(Asm, TLOF.getDwarfRangesSection(),
27902883 "debug_range");
27912884
2885 DwarfDebugLocSectionSym = EmitSectionSym(Asm, TLOF.getDwarfLocSection(),
2886 "section_debug_loc");
2887
27922888 TextSectionSym = EmitSectionSym(Asm, TLOF.getTextSection(), "text_begin");
27932889 EmitSectionSym(Asm, TLOF.getDataSection());
27942890 }
28382934 V->getValue(),
28392935 DwarfDebugRangeSectionSym,
28402936 4);
2937 break;
2938 }
2939 case dwarf::DW_AT_location: {
2940 if (UseDotDebugLocEntry.count(Die) != 0) {
2941 DIELabel *L = cast(Values[i]);
2942 Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4);
2943 } else
2944 Values[i]->EmitValue(Asm, Form);
28412945 break;
28422946 }
28432947 default:
33553459 void DwarfDebug::emitDebugLoc() {
33563460 // Start the dwarf loc section.
33573461 Asm->OutStreamer.SwitchSection(
3358 Asm->getObjFileLowering().getDwarfLocSection());
3462 Asm->getObjFileLowering().getDwarfLocSection());
3463 unsigned char Size = Asm->getTargetData().getPointerSize();
3464 unsigned index = 0;
3465 bool needMarker = true;
3466 for (SmallVector::iterator I = DotDebugLocEntries.begin(),
3467 E = DotDebugLocEntries.end(); I != E; ++I, ++index) {
3468 DotDebugLocEntry Entry = *I;
3469 if (needMarker) {
3470 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", index));
3471 needMarker = false;
3472 }
3473 if (Entry.isEmpty()) {
3474 Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0);
3475 Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0);
3476 needMarker = true;
3477 } else {
3478 Asm->OutStreamer.EmitSymbolValue(Entry.Begin, Size, 0);
3479 Asm->OutStreamer.EmitSymbolValue(Entry.End, Size, 0);
3480 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
3481 unsigned Reg = RI->getDwarfRegNum(Entry.Loc.getReg(), false);
3482 if (Reg < 32) {
3483 Asm->OutStreamer.AddComment("Loc expr size");
3484 Asm->EmitInt16(1);
3485 Asm->EmitInt8(dwarf::DW_OP_reg0 + Reg);
3486 } else {
3487 Asm->OutStreamer.AddComment("Loc expr size");
3488 Asm->EmitInt16(1+MCAsmInfo::getULEB128Size(Reg));
3489 Asm->EmitInt8(dwarf::DW_OP_regx);
3490 Asm->EmitULEB128(Reg);
3491 }
3492 }
3493 }
33593494 }
33603495
33613496 /// EmitDebugARanges - Emit visible names into a debug aranges section.
1414 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
1515
1616 #include "llvm/CodeGen/AsmPrinter.h"
17 #include "llvm/CodeGen/MachineLocation.h"
1718 #include "DIE.h"
1819 #include "llvm/ADT/DenseMap.h"
1920 #include "llvm/ADT/FoldingSet.h"
2930 class DbgScope;
3031 class DbgVariable;
3132 class MachineFrameInfo;
32 class MachineLocation;
3333 class MachineModuleInfo;
3434 class MachineOperand;
3535 class MCAsmInfo;
180180 /// DbgVariableLabelsMap - Maps DbgVariable to corresponding MCSymbol.
181181 DenseMap DbgVariableLabelsMap;
182182
183 /// DotDebugLocEntry - This struct describes location entries emitted in
184 /// .debug_loc section.
185 typedef struct DotDebugLocEntry {
186 const MCSymbol *Begin;
187 const MCSymbol *End;
188 MachineLocation Loc;
189 DotDebugLocEntry() : Begin(0), End(0) {}
190 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
191 MachineLocation &L) : Begin(B), End(E), Loc(L) {}
192 /// Empty entries are also used as a trigger to emit temp label. Such
193 /// labels are referenced is used to find debug_loc offset for a given DIE.
194 bool isEmpty() { return Begin == 0 && End == 0; }
195 } DotDebugLocEntry;
196
197 /// DotDebugLocEntries - Collection of DotDebugLocEntry.
198 SmallVector DotDebugLocEntries;
199
200 /// UseDotDebugLocEntry - DW_AT_location attributes for the DIEs in this set
201 /// idetifies corresponding .debug_loc entry offset.
202 SmallPtrSet UseDotDebugLocEntry;
203
183204 /// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
184205 /// DbgVariable, if any.
185206 DenseMap VarToAbstractVarMap;
199220
200221 /// InlineInfo - Keep track of inlined functions and their location. This
201222 /// information is used to populate debug_inlined section.
202 typedef std::pair<MCSymbol *, DIE *> InlineInfoLabels;
223 typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
203224 DenseMap > InlineInfo;
204225 SmallVector InlinedSPNodes;
205226
233254 // section offsets and are created by EmitSectionLabels.
234255 MCSymbol *DwarfFrameSectionSym, *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
235256 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
236
237 MCSymbol *FunctionBeginSym;
257 MCSymbol *DwarfDebugLocSectionSym;
258 MCSymbol *FunctionBeginSym, *FunctionEndSym;
238259 private:
239260
240261 /// getSourceDirectoryAndFileIds - Return the directory and file ids that
599620 ///
600621 void endFunction(const MachineFunction *MF);
601622
623 /// getLabelBeforeInsn - Return Label preceding the instruction.
624 const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
625
626 /// getLabelAfterInsn - Return Label immediately following the instruction.
627 const MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
628
602629 /// beginScope - Process beginning of a scope.
603630 void beginScope(const MachineInstr *MI);
604631
0 ; RUN: llc -O2 < %s | grep debug_loc13
1 ; Test to check .debug_loc support. This test case emits 14 debug_loc entries.
2
3 %0 = type { double }
4
5 define hidden %0 @__divsc3(float %a, float %b, float %c, float %d) nounwind readnone {
6 entry:
7 tail call void @llvm.dbg.value(metadata !{float %a}, i64 0, metadata !0)
8 tail call void @llvm.dbg.value(metadata !{float %b}, i64 0, metadata !11)
9 tail call void @llvm.dbg.value(metadata !{float %c}, i64 0, metadata !12)
10 tail call void @llvm.dbg.value(metadata !{float %d}, i64 0, metadata !13)
11 %0 = tail call float @fabsf(float %c) nounwind readnone, !dbg !19 ; [#uses=1]
12 %1 = tail call float @fabsf(float %d) nounwind readnone, !dbg !19 ; [#uses=1]
13 %2 = fcmp olt float %0, %1, !dbg !19 ; [#uses=1]
14 br i1 %2, label %bb, label %bb1, !dbg !19
15
16 bb: ; preds = %entry
17 %3 = fdiv float %c, %d, !dbg !20 ; [#uses=3]
18 tail call void @llvm.dbg.value(metadata !{float %3}, i64 0, metadata !16), !dbg !20
19 %4 = fmul float %3, %c, !dbg !21 ; [#uses=1]
20 %5 = fadd float %4, %d, !dbg !21 ; [#uses=2]
21 tail call void @llvm.dbg.value(metadata !{float %5}, i64 0, metadata !14), !dbg !21
22 %6 = fmul float %3, %a, !dbg !22 ; [#uses=1]
23 %7 = fadd float %6, %b, !dbg !22 ; [#uses=1]
24 %8 = fdiv float %7, %5, !dbg !22 ; [#uses=1]
25 tail call void @llvm.dbg.value(metadata !{float %8}, i64 0, metadata !17), !dbg !22
26 %9 = fmul float %3, %b, !dbg !23 ; [#uses=1]
27 %10 = fsub float %9, %a, !dbg !23 ; [#uses=1]
28 %11 = fdiv float %10, %5, !dbg !23 ; [#uses=1]
29 tail call void @llvm.dbg.value(metadata !{float %11}, i64 0, metadata !18), !dbg !23
30 br label %bb2, !dbg !23
31
32 bb1: ; preds = %entry
33 %12 = fdiv float %d, %c, !dbg !24 ; [#uses=3]
34 tail call void @llvm.dbg.value(metadata !{float %12}, i64 0, metadata !16), !dbg !24
35 %13 = fmul float %12, %d, !dbg !25 ; [#uses=1]
36 %14 = fadd float %13, %c, !dbg !25 ; [#uses=2]
37 tail call void @llvm.dbg.value(metadata !{float %14}, i64 0, metadata !14), !dbg !25
38 %15 = fmul float %12, %b, !dbg !26 ; [#uses=1]
39 %16 = fadd float %15, %a, !dbg !26 ; [#uses=1]
40 %17 = fdiv float %16, %14, !dbg !26 ; [#uses=1]
41 tail call void @llvm.dbg.value(metadata !{float %17}, i64 0, metadata !17), !dbg !26
42 %18 = fmul float %12, %a, !dbg !27 ; [#uses=1]
43 %19 = fsub float %b, %18, !dbg !27 ; [#uses=1]
44 %20 = fdiv float %19, %14, !dbg !27 ; [#uses=1]
45 tail call void @llvm.dbg.value(metadata !{float %20}, i64 0, metadata !18), !dbg !27
46 br label %bb2, !dbg !27
47
48 bb2: ; preds = %bb1, %bb
49 %y.0 = phi float [ %11, %bb ], [ %20, %bb1 ] ; [#uses=5]
50 %x.0 = phi float [ %8, %bb ], [ %17, %bb1 ] ; [#uses=5]
51 %21 = fcmp uno float %x.0, 0.000000e+00, !dbg !28 ; [#uses=1]
52 %22 = fcmp uno float %y.0, 0.000000e+00, !dbg !28 ; [#uses=1]
53 %or.cond = and i1 %21, %22 ; [#uses=1]
54 br i1 %or.cond, label %bb4, label %bb46, !dbg !28
55
56 bb4: ; preds = %bb2
57 %23 = fcmp une float %c, 0.000000e+00, !dbg !29 ; [#uses=1]
58 %24 = fcmp une float %d, 0.000000e+00, !dbg !29 ; [#uses=1]
59 %or.cond93 = or i1 %23, %24 ; [#uses=1]
60 br i1 %or.cond93, label %bb9, label %bb6, !dbg !29
61
62 bb6: ; preds = %bb4
63 %25 = fcmp uno float %a, 0.000000e+00, !dbg !29 ; [#uses=1]
64 %26 = fcmp uno float %b, 0.000000e+00, !dbg !29 ; [#uses=1]
65 %or.cond94 = and i1 %25, %26 ; [#uses=1]
66 br i1 %or.cond94, label %bb9, label %bb8, !dbg !29
67
68 bb8: ; preds = %bb6
69 %27 = tail call float @copysignf(float 0x7FF0000000000000, float %c) nounwind readnone, !dbg !30 ; [#uses=2]
70 %28 = fmul float %27, %a, !dbg !30 ; [#uses=1]
71 tail call void @llvm.dbg.value(metadata !{float %28}, i64 0, metadata !17), !dbg !30
72 %29 = fmul float %27, %b, !dbg !31 ; [#uses=1]
73 tail call void @llvm.dbg.value(metadata !{float %29}, i64 0, metadata !18), !dbg !31
74 br label %bb46, !dbg !31
75
76 bb9: ; preds = %bb6, %bb4
77 %30 = fcmp ord float %a, 0.000000e+00 ; [#uses=1]
78 %31 = fsub float %a, %a, !dbg !32 ; [#uses=3]
79 %32 = fcmp uno float %31, 0.000000e+00 ; [#uses=1]
80 %33 = and i1 %30, %32, !dbg !32 ; [#uses=2]
81 br i1 %33, label %bb14, label %bb11, !dbg !32
82
83 bb11: ; preds = %bb9
84 %34 = fcmp ord float %b, 0.000000e+00 ; [#uses=1]
85 %35 = fsub float %b, %b, !dbg !32 ; [#uses=1]
86 %36 = fcmp uno float %35, 0.000000e+00 ; [#uses=1]
87 %37 = and i1 %34, %36, !dbg !32 ; [#uses=1]
88 br i1 %37, label %bb14, label %bb27, !dbg !32
89
90 bb14: ; preds = %bb11, %bb9
91 %38 = fsub float %c, %c, !dbg !32 ; [#uses=1]
92 %39 = fcmp ord float %38, 0.000000e+00 ; [#uses=1]
93 br i1 %39, label %bb15, label %bb27, !dbg !32
94
95 bb15: ; preds = %bb14
96 %40 = fsub float %d, %d, !dbg !32 ; [#uses=1]
97 %41 = fcmp ord float %40, 0.000000e+00 ; [#uses=1]
98 br i1 %41, label %bb16, label %bb27, !dbg !32
99
100 bb16: ; preds = %bb15
101 %iftmp.0.0 = select i1 %33, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
102 %42 = tail call float @copysignf(float %iftmp.0.0, float %a) nounwind readnone, !dbg !33 ; [#uses=2]
103 tail call void @llvm.dbg.value(metadata !{float %42}, i64 0, metadata !0), !dbg !33
104 %43 = fcmp ord float %b, 0.000000e+00 ; [#uses=1]
105 %44 = fsub float %b, %b, !dbg !34 ; [#uses=1]
106 %45 = fcmp uno float %44, 0.000000e+00 ; [#uses=1]
107 %46 = and i1 %43, %45, !dbg !34 ; [#uses=1]
108 %iftmp.1.0 = select i1 %46, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
109 %47 = tail call float @copysignf(float %iftmp.1.0, float %b) nounwind readnone, !dbg !34 ; [#uses=2]
110 tail call void @llvm.dbg.value(metadata !{float %47}, i64 0, metadata !11), !dbg !34
111 %48 = fmul float %42, %c, !dbg !35 ; [#uses=1]
112 %49 = fmul float %47, %d, !dbg !35 ; [#uses=1]
113 %50 = fadd float %48, %49, !dbg !35 ; [#uses=1]
114 %51 = fmul float %50, 0x7FF0000000000000, !dbg !35 ; [#uses=1]
115 tail call void @llvm.dbg.value(metadata !{float %51}, i64 0, metadata !17), !dbg !35
116 %52 = fmul float %47, %c, !dbg !36 ; [#uses=1]
117 %53 = fmul float %42, %d, !dbg !36 ; [#uses=1]
118 %54 = fsub float %52, %53, !dbg !36 ; [#uses=1]
119 %55 = fmul float %54, 0x7FF0000000000000, !dbg !36 ; [#uses=1]
120 tail call void @llvm.dbg.value(metadata !{float %55}, i64 0, metadata !18), !dbg !36
121 br label %bb46, !dbg !36
122
123 bb27: ; preds = %bb15, %bb14, %bb11
124 %56 = fcmp ord float %c, 0.000000e+00 ; [#uses=1]
125 %57 = fsub float %c, %c, !dbg !37 ; [#uses=1]
126 %58 = fcmp uno float %57, 0.000000e+00 ; [#uses=1]
127 %59 = and i1 %56, %58, !dbg !37 ; [#uses=2]
128 br i1 %59, label %bb33, label %bb30, !dbg !37
129
130 bb30: ; preds = %bb27
131 %60 = fcmp ord float %d, 0.000000e+00 ; [#uses=1]
132 %61 = fsub float %d, %d, !dbg !37 ; [#uses=1]
133 %62 = fcmp uno float %61, 0.000000e+00 ; [#uses=1]
134 %63 = and i1 %60, %62, !dbg !37 ; [#uses=1]
135 %64 = fcmp ord float %31, 0.000000e+00 ; [#uses=1]
136 %or.cond95 = and i1 %63, %64 ; [#uses=1]
137 br i1 %or.cond95, label %bb34, label %bb46, !dbg !37
138
139 bb33: ; preds = %bb27
140 %.old = fcmp ord float %31, 0.000000e+00 ; [#uses=1]
141 br i1 %.old, label %bb34, label %bb46, !dbg !37
142
143 bb34: ; preds = %bb33, %bb30
144 %65 = fsub float %b, %b, !dbg !37 ; [#uses=1]
145 %66 = fcmp ord float %65, 0.000000e+00 ; [#uses=1]
146 br i1 %66, label %bb35, label %bb46, !dbg !37
147
148 bb35: ; preds = %bb34
149 %iftmp.2.0 = select i1 %59, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
150 %67 = tail call float @copysignf(float %iftmp.2.0, float %c) nounwind readnone, !dbg !38 ; [#uses=2]
151 tail call void @llvm.dbg.value(metadata !{float %67}, i64 0, metadata !12), !dbg !38
152 %68 = fcmp ord float %d, 0.000000e+00 ; [#uses=1]
153 %69 = fsub float %d, %d, !dbg !39 ; [#uses=1]
154 %70 = fcmp uno float %69, 0.000000e+00 ; [#uses=1]
155 %71 = and i1 %68, %70, !dbg !39 ; [#uses=1]
156 %iftmp.3.0 = select i1 %71, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
157 %72 = tail call float @copysignf(float %iftmp.3.0, float %d) nounwind readnone, !dbg !39 ; [#uses=2]
158 tail call void @llvm.dbg.value(metadata !{float %72}, i64 0, metadata !13), !dbg !39
159 %73 = fmul float %67, %a, !dbg !40 ; [#uses=1]
160 %74 = fmul float %72, %b, !dbg !40 ; [#uses=1]
161 %75 = fadd float %73, %74, !dbg !40 ; [#uses=1]
162 %76 = fmul float %75, 0.000000e+00, !dbg !40 ; [#uses=1]
163 tail call void @llvm.dbg.value(metadata !{float %76}, i64 0, metadata !17), !dbg !40
164 %77 = fmul float %67, %b, !dbg !41 ; [#uses=1]
165 %78 = fmul float %72, %a, !dbg !41 ; [#uses=1]
166 %79 = fsub float %77, %78, !dbg !41 ; [#uses=1]
167 %80 = fmul float %79, 0.000000e+00, !dbg !41 ; [#uses=1]
168 tail call void @llvm.dbg.value(metadata !{float %80}, i64 0, metadata !18), !dbg !41
169 br label %bb46, !dbg !41
170
171 bb46: ; preds = %bb35, %bb34, %bb33, %bb30, %bb16, %bb8, %bb2
172 %y.1 = phi float [ %80, %bb35 ], [ %y.0, %bb34 ], [ %y.0, %bb33 ], [ %y.0, %bb30 ], [ %55, %bb16 ], [ %29, %bb8 ], [ %y.0, %bb2 ] ; [#uses=2]
173 %x.1 = phi float [ %76, %bb35 ], [ %x.0, %bb34 ], [ %x.0, %bb33 ], [ %x.0, %bb30 ], [ %51, %bb16 ], [ %28, %bb8 ], [ %x.0, %bb2 ] ; [#uses=1]
174 %81 = fmul float %y.1, 0.000000e+00, !dbg !42 ; [#uses=1]
175 %82 = fadd float %y.1, 0.000000e+00, !dbg !42 ; [#uses=1]
176 %tmpr = fadd float %x.1, %81, !dbg !42 ; [#uses=1]
177 %tmp89 = bitcast float %tmpr to i32 ; [#uses=1]
178 %tmp90 = zext i32 %tmp89 to i64 ; [#uses=1]
179 %tmp85 = bitcast float %82 to i32 ; [#uses=1]
180 %tmp86 = zext i32 %tmp85 to i64 ; [#uses=1]
181 %tmp87 = shl i64 %tmp86, 32 ; [#uses=1]
182 %ins = or i64 %tmp90, %tmp87 ; [#uses=1]
183 %tmp84 = bitcast i64 %ins to double ; [#uses=1]
184 %mrv75 = insertvalue %0 undef, double %tmp84, 0, !dbg !42 ; <%0> [#uses=1]
185 ret %0 %mrv75, !dbg !42
186 }
187
188 declare float @fabsf(float)
189
190 declare float @copysignf(float, float) nounwind readnone
191
192 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
193
194 !llvm.dbg.lv = !{!0, !11, !12, !13, !14, !16, !17, !18}
195
196 !0 = metadata !{i32 524545, metadata !1, metadata !"a", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
197 !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 ]
198 !2 = metadata !{i32 524329, metadata !"libgcc2.c", metadata !"/Users/yash/clean/LG.D/gcc/../../llvmgcc/gcc", metadata !3} ; [ DW_TAG_file_type ]
199 !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 ]
200 !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 ]
201 !5 = metadata !{metadata !6, metadata !9, metadata !9, metadata !9, metadata !9}
202 !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 ]
203 !7 = metadata !{i32 524329, metadata !"libgcc2.h", metadata !"/Users/yash/clean/LG.D/gcc/../../llvmgcc/gcc", metadata !3} ; [ DW_TAG_file_type ]
204 !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 ]
205 !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 ]
206 !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 ]
207 !11 = metadata !{i32 524545, metadata !1, metadata !"b", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
208 !12 = metadata !{i32 524545, metadata !1, metadata !"c", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
209 !13 = metadata !{i32 524545, metadata !1, metadata !"d", metadata !2, i32 1921, metadata !9} ; [ DW_TAG_arg_variable ]
210 !14 = metadata !{i32 524544, metadata !15, metadata !"denom", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
211 !15 = metadata !{i32 524299, metadata !1, i32 1922, i32 0} ; [ DW_TAG_lexical_block ]
212 !16 = metadata !{i32 524544, metadata !15, metadata !"ratio", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
213 !17 = metadata !{i32 524544, metadata !15, metadata !"x", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
214 !18 = metadata !{i32 524544, metadata !15, metadata !"y", metadata !2, i32 1923, metadata !9} ; [ DW_TAG_auto_variable ]
215 !19 = metadata !{i32 1929, i32 0, metadata !15, null}
216 !20 = metadata !{i32 1931, i32 0, metadata !15, null}
217 !21 = metadata !{i32 1932, i32 0, metadata !15, null}
218 !22 = metadata !{i32 1933, i32 0, metadata !15, null}
219 !23 = metadata !{i32 1934, i32 0, metadata !15, null}
220 !24 = metadata !{i32 1938, i32 0, metadata !15, null}
221 !25 = metadata !{i32 1939, i32 0, metadata !15, null}
222 !26 = metadata !{i32 1940, i32 0, metadata !15, null}
223 !27 = metadata !{i32 1941, i32 0, metadata !15, null}
224 !28 = metadata !{i32 1946, i32 0, metadata !15, null}
225 !29 = metadata !{i32 1948, i32 0, metadata !15, null}
226 !30 = metadata !{i32 1950, i32 0, metadata !15, null}
227 !31 = metadata !{i32 1951, i32 0, metadata !15, null}
228 !32 = metadata !{i32 1953, i32 0, metadata !15, null}
229 !33 = metadata !{i32 1955, i32 0, metadata !15, null}
230 !34 = metadata !{i32 1956, i32 0, metadata !15, null}
231 !35 = metadata !{i32 1957, i32 0, metadata !15, null}
232 !36 = metadata !{i32 1958, i32 0, metadata !15, null}
233 !37 = metadata !{i32 1960, i32 0, metadata !15, null}
234 !38 = metadata !{i32 1962, i32 0, metadata !15, null}
235 !39 = metadata !{i32 1963, i32 0, metadata !15, null}
236 !40 = metadata !{i32 1964, i32 0, metadata !15, null}
237 !41 = metadata !{i32 1965, i32 0, metadata !15, null}
238 !42 = metadata !{i32 1969, i32 0, metadata !15, null}