llvm.org GIT mirror llvm / de4845c
Switch the code generator (except the JIT) onto the new DebugLoc representation. This eliminates the 'DILocation' MDNodes for file/line/col tuples from -O0 -g codegen. This remove the old DebugLoc class, making it a typedef for DebugLoc, I'll rename NewDebugLoc next. I didn't update the JIT to use the new apis, so it will continue to work, but be as slow as before. Someone should eventually do this or, better yet, rip out the JIT debug info stuff and build the JIT on top of MC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100209 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
16 changed file(s) with 133 addition(s) and 208 deletion(s). Raw diff Collapse all Expand all
3030 class Type;
3131 class Value;
3232 class DbgDeclareInst;
33 class DebugLoc;
34 struct DebugLocTracker;
3533 class Instruction;
3634 class MDNode;
3735 class LLVMContext;
709707 std::string &Type, unsigned &LineNo, std::string &File,
710708 std::string &Dir);
711709
712 /// ExtractDebugLocation - Extract debug location information
713 /// from DILocation.
714 DebugLoc ExtractDebugLocation(DILocation &Loc,
715 DebugLocTracker &DebugLocInfo);
716
717710 /// getDISubprogram - Find subprogram that is enclosing this scope.
718711 DISubprogram getDISubprogram(MDNode *Scope);
719712
2525
2626 namespace llvm {
2727
28 class DILocation;
2928 class Value;
3029 class Function;
3130 class MachineRegisterInfo;
111110 // of a function.
112111 DebugLoc DefaultDebugLoc;
113112
114 // Tracks debug locations.
115 DebugLocTracker DebugLocInfo;
116
117113 /// FunctionNumber - This provides a unique ID for each function emitted in
118114 /// this translation unit.
119115 ///
401397 // Debug location.
402398 //
403399
404 /// getDILocation - Get the DILocation for a given DebugLoc object.
405 DILocation getDILocation(DebugLoc DL) const;
406
407400 /// getDefaultDebugLoc - Get the default debug location for the machine
408401 /// function.
409402 DebugLoc getDefaultDebugLoc() const { return DefaultDebugLoc; }
411404 /// setDefaultDebugLoc - Get the default debug location for the machine
412405 /// function.
413406 void setDefaultDebugLoc(DebugLoc DL) { DefaultDebugLoc = DL; }
414
415 /// getDebugLocInfo - Get the debug info location tracker.
416 DebugLocTracker &getDebugLocInfo() { return DebugLocInfo; }
417407 };
418408
419409 //===--------------------------------------------------------------------===//
3636 #include "llvm/CodeGen/MachineLocation.h"
3737 #include "llvm/MC/MCContext.h"
3838 #include "llvm/Support/Dwarf.h"
39 #include "llvm/Support/DebugLoc.h"
3940 #include "llvm/Support/ValueHandle.h"
4041 #include "llvm/System/DataTypes.h"
4142 #include "llvm/ADT/DenseMap.h"
155156 public:
156157 static char ID; // Pass identification, replacement for typeid
157158
158 typedef std::pair > UnsignedAndMDNodePair;
159 typedef SmallVector< std::pair, UnsignedAndMDNodePair>, 4>
159 typedef std::pair UnsignedDebugLocPair;
160 typedef SmallVector, UnsignedDebugLocPair>, 4>
160161 VariableDbgInfoMapTy;
161162 VariableDbgInfoMapTy VariableDbgInfo;
162163
329330 /// of one is required to emit exception handling info.
330331 Function *getPersonality() const;
331332
332 /// setVariableDbgInfo - Collect information used to emit debugging information
333 /// of a variable.
334 void setVariableDbgInfo(MDNode *N, unsigned Slot, MDNode *Scope) {
335 VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Scope)));
333 /// setVariableDbgInfo - Collect information used to emit debugging
334 /// information of a variable.
335 void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc) {
336 VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Loc)));
336337 }
337338
338339 VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; }
7676 return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx;
7777 }
7878 bool operator!=(const NewDebugLoc &DL) const { return !(*this == DL); }
79
80
81
82
83 static NewDebugLoc getUnknownLoc() { NewDebugLoc L; return L; }
7984 };
8085
8186
87 typedef NewDebugLoc DebugLoc;
8288
83 /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
84 /// to index into a vector of unique debug location tuples.
85 class DebugLoc {
86 unsigned Idx;
87 public:
88 DebugLoc() : Idx(~0U) {} // Defaults to invalid.
89
90 static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; }
91 static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
92
93 unsigned getIndex() const { return Idx; }
94
95 /// isUnknown - Return true if there is no debug info for the SDNode /
96 /// MachineInstr.
97 bool isUnknown() const { return Idx == ~0U; }
98
99 bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; }
100 bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
101 };
102
103 /// DebugLocTracker - This class tracks debug location information.
104 ///
105 struct DebugLocTracker {
106 /// DebugLocations - A vector of unique DebugLocTuple's.
107 ///
108 std::vector DebugLocations;
109
110 /// DebugIdMap - This maps DebugLocTuple's to indices into the
111 /// DebugLocations vector.
112 DenseMap DebugIdMap;
113
114 DebugLocTracker() {}
115 };
116
11789 } // end namespace llvm
11890
11991 #endif /* LLVM_DEBUGLOC_H */
2323 #include "llvm/ADT/SmallPtrSet.h"
2424 #include "llvm/Support/Debug.h"
2525 #include "llvm/Support/Dwarf.h"
26 #include "llvm/Support/DebugLoc.h"
2726 #include "llvm/Support/raw_ostream.h"
2827 using namespace llvm;
2928 using namespace llvm::dwarf;
13711370 return true;
13721371 }
13731372
1374 /// ExtractDebugLocation - Extract debug location information
1375 /// from DILocation.
1376 DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
1377 DebugLocTracker &DebugLocInfo) {
1378 DenseMap::iterator II
1379 = DebugLocInfo.DebugIdMap.find(Loc.getNode());
1380 if (II != DebugLocInfo.DebugIdMap.end())
1381 return DebugLoc::get(II->second);
1382
1383 // Add a new location entry.
1384 unsigned Id = DebugLocInfo.DebugLocations.size();
1385 DebugLocInfo.DebugLocations.push_back(Loc.getNode());
1386 DebugLocInfo.DebugIdMap[Loc.getNode()] = Id;
1387
1388 return DebugLoc::get(Id);
1389 }
1390
13911373 /// getDISubprogram - Find subprogram that is enclosing this scope.
13921374 DISubprogram llvm::getDISubprogram(MDNode *Scope) {
13931375 DIDescriptor D(Scope);
339339 const MachineFunction *MF = MI.getParent()->getParent();
340340 const TargetMachine &TM = MF->getTarget();
341341
342 if (!MI.getDebugLoc().isUnknown()) {
343 DILocation DLT = MF->getDILocation(MI.getDebugLoc());
344
345 // Print source line info.
346 DIScope Scope = DLT.getScope();
342 DebugLoc DL = MI.getDebugLoc();
343 if (!DL.isUnknown()) { // Print source line info.
344 DIScope Scope(DL.getScope(MF->getFunction()->getContext()));
347345 // Omit the directory, because it's likely to be long and uninteresting.
348346 if (Scope.Verify())
349347 CommentOS << Scope.getFilename();
350348 else
351349 CommentOS << "";
352 CommentOS << ':' << DLT.getLineNumber();
353 if (DLT.getColumnNumber() != 0)
354 CommentOS << ':' << DLT.getColumnNumber();
350 CommentOS << ':' << DL.getLine();
351 if (DL.getCol() != 0)
352 CommentOS << ':' << DL.getCol();
355353 CommentOS << '\n';
356354 }
357355
301301 : DwarfPrinter(OS, A, T), ModuleCU(0),
302302 AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
303303 DIEBlocks(), SectionSourceLines(), didInitial(false), shouldEmit(false),
304 CurrentFnDbgScope(0), PrevDILoc(0), DebugTimer(0) {
304 CurrentFnDbgScope(0), DebugTimer(0) {
305305 NextStringPoolNumber = 0;
306306 if (TimePassesIsEnabled)
307307 DebugTimer = new Timer("Dwarf Debug Writer");
19311931 /// findAbstractVariable - Find abstract variable, if any, associated with Var.
19321932 DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
19331933 unsigned FrameIdx,
1934 DILocation &ScopeLoc) {
1934 DebugLoc ScopeLoc) {
19351935
19361936 DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode());
19371937 if (AbsDbgVariable)
19381938 return AbsDbgVariable;
19391939
1940 DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope().getNode());
1940 LLVMContext &Ctx = Var.getNode()->getContext();
1941 DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx));
19411942 if (!Scope)
19421943 return NULL;
19431944
19521953 /// FIXME : Refactor findAbstractVariable.
19531954 DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
19541955 const MachineInstr *MI,
1955 DILocation &ScopeLoc) {
1956 DebugLoc ScopeLoc) {
19561957
19571958 DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode());
19581959 if (AbsDbgVariable)
19591960 return AbsDbgVariable;
19601961
1961 DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope().getNode());
1962 LLVMContext &Ctx = Var.getNode()->getContext();
1963 DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx));
19621964 if (!Scope)
19631965 return NULL;
19641966
19741976 void DwarfDebug::collectVariableInfo() {
19751977 if (!MMI) return;
19761978
1979 const LLVMContext &Ctx = MF->getFunction()->getContext();
1980
19771981 MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
19781982 for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
19791983 VE = VMap.end(); VI != VE; ++VI) {
19801984 MDNode *Var = VI->first;
19811985 if (!Var) continue;
1982 DIVariable DV (Var);
1983 std::pair< unsigned, MDNode *> VP = VI->second;
1984 DILocation ScopeLoc(VP.second);
1985
1986 DbgScope *Scope =
1987 ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode());
1988 if (!Scope)
1989 Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode());
1986 DIVariable DV(Var);
1987 const std::pair &VP = VI->second;
1988
1989 DbgScope *Scope = 0;
1990 if (MDNode *IA = VP.second.getInlinedAt(Ctx))
1991 Scope = ConcreteScopes.lookup(IA);
1992 if (Scope == 0)
1993 Scope = DbgScopeMap.lookup(VP.second.getScope(Ctx));
1994
19901995 // If variable scope is not found then skip this variable.
1991 if (!Scope)
1996 if (Scope == 0)
19921997 continue;
19931998
1994 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.first, ScopeLoc);
1999 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.first, VP.second);
19952000 DbgVariable *RegVar = new DbgVariable(DV, VP.first, AbsDbgVariable);
19962001 Scope->addVariable(RegVar);
19972002 }
20202025
20212026 DebugLoc DL = MInsn->getDebugLoc();
20222027 if (DL.isUnknown()) continue;
2023 DILocation ScopeLoc = MF->getDILocation(DL);
2024 DbgScope *Scope =
2025 ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode());
2026 if (!Scope)
2027 Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode());
2028 DbgScope *Scope = 0;
2029 if (MDNode *IA = DL.getInlinedAt(Ctx))
2030 Scope = ConcreteScopes.lookup(IA);
2031 if (Scope == 0)
2032 Scope = DbgScopeMap.lookup(DL.getScope(Ctx));
2033
20282034 // If variable scope is not found then skip this variable.
2029 if (!Scope)
2035 if (Scope == 0)
20302036 continue;
20312037
2032 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, ScopeLoc);
2038 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, DL);
20332039 DbgVariable *RegVar = new DbgVariable(DV, MInsn, AbsDbgVariable);
20342040 DbgValueStartMap[MInsn] = RegVar;
20352041 Scope->addVariable(RegVar);
20432049 DebugLoc DL = MI->getDebugLoc();
20442050 if (DL.isUnknown())
20452051 return;
2046 DILocation DILoc = MF->getDILocation(DL);
2047 if (!DILoc.getScope().Verify())
2048 return;
20492052
20502053 // Check and update last known location info.
2051 if(DILoc.getNode() == PrevDILoc)
2054 if (DL == PrevInstLoc)
2055 return;
2056
2057 MDNode *Scope = DL.getScope(MF->getFunction()->getContext());
2058
2059 // FIXME: Should only verify each scope once!
2060 if (!DIScope(Scope).Verify())
20522061 return;
20532062
20542063 // DBG_VALUE instruction establishes new value.
20562065 DenseMap::iterator DI
20572066 = DbgValueStartMap.find(MI);
20582067 if (DI != DbgValueStartMap.end()) {
2059 MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(),
2060 DILoc.getColumnNumber(),
2061 DILoc.getScope().getNode());
2062 PrevDILoc = DILoc.getNode();
2068 MCSymbol *Label = recordSourceLine(DL.getLine(), DL.getCol(), Scope);
2069 PrevInstLoc = DL;
20632070 DI->second->setDbgValueLabel(Label);
20642071 }
20652072 return;
20672074
20682075 // Emit a label to indicate location change. This is used for line
20692076 // table even if this instruction does start a new scope.
2070 MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(),
2071 DILoc.getColumnNumber(),
2072 DILoc.getScope().getNode());
2073 PrevDILoc = DILoc.getNode();
2077 MCSymbol *Label = recordSourceLine(DL.getLine(), DL.getCol(), Scope);
2078 PrevInstLoc = DL;
20742079
20752080 // update DbgScope if this instruction starts a new scope.
20762081 InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI);
20932098 DebugLoc DL = MI->getDebugLoc();
20942099 if (DL.isUnknown())
20952100 return;
2096 DILocation DILoc = MF->getDILocation(DL);
2097 if (!DILoc.getScope().Verify())
2098 return;
2099
2101
21002102 // Emit a label and update DbgScope if this instruction ends a scope.
21012103 InsnToDbgScopeMapTy::iterator I = DbgScopeEndMap.find(MI);
21022104 if (I == DbgScopeEndMap.end())
21032105 return;
2104
2106
21052107 MCSymbol *Label = MMI->getContext().CreateTempSymbol();
21062108 Asm->OutStreamer.EmitLabel(Label);
21072109
21142116
21152117 /// createDbgScope - Create DbgScope for the scope.
21162118 void DwarfDebug::createDbgScope(MDNode *Scope, MDNode *InlinedAt) {
2117
21182119 if (!InlinedAt) {
21192120 DbgScope *WScope = DbgScopeMap.lookup(Scope);
21202121 if (WScope)
21462147
21472148 DenseMap MIIndexMap;
21482149 unsigned MIIndex = 0;
2150 LLVMContext &Ctx = MF->getFunction()->getContext();
2151
21492152 // Scan each instruction and create scopes. First build working set of scopes.
21502153 for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
21512154 I != E; ++I) {
21552158 // FIXME : Remove DBG_VALUE check.
21562159 if (MInsn->isDebugValue()) continue;
21572160 MIIndexMap[MInsn] = MIIndex++;
2161
21582162 DebugLoc DL = MInsn->getDebugLoc();
21592163 if (DL.isUnknown()) continue;
2160 DILocation DLT = MF->getDILocation(DL);
2161 DIScope DLTScope = DLT.getScope();
2162 if (!DLTScope.getNode()) continue;
2164
2165 MDNode *Scope = DL.getScope(Ctx);
2166
21632167 // There is no need to create another DIE for compile unit. For all
21642168 // other scopes, create one DbgScope now. This will be translated
21652169 // into a scope DIE at the end.
2166 if (DLTScope.isCompileUnit()) continue;
2167 createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode());
2170 if (DIScope(Scope).isCompileUnit()) continue;
2171 createDbgScope(Scope, DL.getInlinedAt(Ctx));
21682172 }
21692173 }
21702174
21782182 // FIXME : Remove DBG_VALUE check.
21792183 if (MInsn->isDebugValue()) continue;
21802184 DebugLoc DL = MInsn->getDebugLoc();
2181 if (DL.isUnknown()) continue;
2182 DILocation DLT = MF->getDILocation(DL);
2183 DIScope DLTScope = DLT.getScope();
2184 if (!DLTScope.getNode()) continue;
2185 if (DL.isUnknown()) continue;
2186
2187 MDNode *Scope = DL.getScope(Ctx);
2188 if (Scope == 0) continue;
2189
21852190 // There is no need to create another DIE for compile unit. For all
21862191 // other scopes, create one DbgScope now. This will be translated
21872192 // into a scope DIE at the end.
2188 if (DLTScope.isCompileUnit()) continue;
2189 DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn,
2190 DLT.getOrigLocation().getNode());
2191 Scope->setLastInsn(MInsn);
2193 if (DIScope(Scope).isCompileUnit()) continue;
2194 DbgScope *DScope = getUpdatedDbgScope(Scope, MInsn, DL.getInlinedAt(Ctx));
2195 DScope->setLastInsn(MInsn);
21922196 }
21932197 }
21942198
22542258 // Emit label for the implicitly defined dbg.stoppoint at the start of the
22552259 // function.
22562260 DebugLoc FDL = MF->getDefaultDebugLoc();
2257 if (!FDL.isUnknown()) {
2258 DILocation DLT = MF->getDILocation(FDL);
2259 DISubprogram SP = getDISubprogram(DLT.getScope().getNode());
2260 unsigned Line, Col;
2261 if (SP.Verify()) {
2262 Line = SP.getLineNumber();
2263 Col = 0;
2264 } else {
2265 Line = DLT.getLineNumber();
2266 Col = DLT.getColumnNumber();
2267 }
2268
2269 recordSourceLine(Line, Col, DLT.getScope().getNode());
2270 }
2261 if (FDL.isUnknown()) return;
2262
2263 MDNode *Scope = FDL.getScope(MF->getFunction()->getContext());
2264
2265 DISubprogram SP = getDISubprogram(Scope);
2266 unsigned Line, Col;
2267 if (SP.Verify()) {
2268 Line = SP.getLineNumber();
2269 Col = 0;
2270 } else {
2271 Line = FDL.getLine();
2272 Col = FDL.getCol();
2273 }
2274
2275 recordSourceLine(Line, Col, Scope);
22712276 }
22722277
22732278 /// endFunction - Gather and emit post-function debug information.
194194
195195 /// Previous instruction's location information. This is used to determine
196196 /// label location to indicate scope boundries in dwarf debug info.
197 mutable const MDNode *PrevDILoc;
197 DebugLoc PrevInstLoc;
198198
199199 /// DebugTimer - Timer for the Dwarf debug writer.
200200 Timer *DebugTimer;
360360
361361 /// getUpdatedDbgScope - Find or create DbgScope assicated with
362362 /// the instruction. Initialize scope and update scope hierarchy.
363 DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt);
363 DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI,
364 MDNode *InlinedAt);
364365
365366 /// createDbgScope - Create DbgScope for the scope.
366367 void createDbgScope(MDNode *Scope, MDNode *InlinedAt);
369370
370371 /// findAbstractVariable - Find abstract variable associated with Var.
371372 DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx,
372 DILocation &Loc);
373 DebugLoc Loc);
373374 DbgVariable *findAbstractVariable(DIVariable &Var, const MachineInstr *MI,
374 DILocation &Loc);
375 DebugLoc Loc);
375376
376377 /// updateSubprogramScopeDIE - Find DIE for the given subprogram and
377378 /// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
435435 return VReg;
436436 }
437437
438 /// getDILocation - Get the DILocation for a given DebugLoc object.
439 DILocation MachineFunction::getDILocation(DebugLoc DL) const {
440 unsigned Idx = DL.getIndex();
441 assert(Idx < DebugLocInfo.DebugLocations.size() &&
442 "Invalid index into debug locations!");
443 return DILocation(DebugLocInfo.DebugLocations[Idx]);
444 }
445
446
447438 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
448439 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
449440 /// normal 'L' label is returned.
12201220
12211221 // TODO: print InlinedAtLoc information
12221222
1223 DILocation DLT = MF->getDILocation(debugLoc);
1224 DIScope Scope = DLT.getScope();
1223 DIScope Scope(debugLoc.getScope(MF->getFunction()->getContext()));
12251224 OS << " dbg:";
12261225 // Omit the directory, since it's usually long and uninteresting.
12271226 if (Scope.Verify())
12281227 OS << Scope.getFilename();
12291228 else
12301229 OS << "";
1231 OS << ':' << DLT.getLineNumber();
1232 if (DLT.getColumnNumber() != 0)
1233 OS << ':' << DLT.getColumnNumber();
1230 OS << ':' << debugLoc.getLine();
1231 if (debugLoc.getCol() != 0)
1232 OS << ':' << debugLoc.getCol();
12341233 }
12351234
12361235 OS << "\n";
339339 StaticAllocaMap.find(AI);
340340 if (SI == StaticAllocaMap.end()) break; // VLAs.
341341 int FI = SI->second;
342 if (MDNode *Dbg = DI->getDbgMetadata())
343 MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
342 if (!DI->getDebugLoc().isUnknown())
343 MMI->setVariableDbgInfo(DI->getVariable(), FI, DI->getDebugLoc());
344344
345345 // Building the map above is target independent. Generating DBG_VALUE
346346 // inline is target dependent; do this now.
37993799 int FI = SI->second;
38003800
38013801 if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo())
3802 if (MDNode *Dbg = DI.getDbgMetadata())
3803 MMI->setVariableDbgInfo(Variable, FI, Dbg);
3802 if (!DI.getDebugLoc().isUnknown())
3803 MMI->setVariableDbgInfo(Variable, FI, DI.getDebugLoc());
38043804 return 0;
38053805 }
38063806 case Intrinsic::dbg_value: {
38503850 if (SI == FuncInfo.StaticAllocaMap.end())
38513851 return 0; // VLAs.
38523852 int FI = SI->second;
3853
38533854 if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo())
3854 if (MDNode *Dbg = DI.getDbgMetadata())
3855 MMI->setVariableDbgInfo(Variable, FI, Dbg);
3855 if (!DI.getDebugLoc().isUnknown())
3856 MMI->setVariableDbgInfo(Variable, FI, DI.getDebugLoc());
38563857 return 0;
38573858 }
38583859 case Intrinsic::eh_exception: {
367367 /// attached with this instruction.
368368 static void SetDebugLoc(Instruction *I, SelectionDAGBuilder *SDB,
369369 FastISel *FastIS, MachineFunction *MF) {
370 MDNode *Dbg = I->getDbgMetadata();
371 if (Dbg == 0) return;
372
373 DILocation DILoc(Dbg);
374 DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo());
375
376 SDB->setCurDebugLoc(Loc);
370 DebugLoc DL = I->getDebugLoc();
371 if (DL.isUnknown()) return;
372
373 SDB->setCurDebugLoc(DL);
377374
378375 if (FastIS)
379 FastIS->setCurDebugLoc(Loc);
376 FastIS->setCurDebugLoc(DL);
380377
381378 // If the function doesn't have a default debug location yet, set
382379 // it. This is kind of a hack.
383380 if (MF->getDefaultDebugLoc().isUnknown())
384 MF->setDefaultDebugLoc(Loc);
381 MF->setDefaultDebugLoc(DL);
385382 }
386383
387384 /// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown.
820820 }
821821
822822 void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) {
823 if (!DL.isUnknown()) {
824 DILocation CurDLT = EmissionDetails.MF->getDILocation(DL);
825
826 if (BeforePrintingInsn) {
827 if (CurDLT.getScope().getNode() != 0
828 && PrevDLT.getNode() != CurDLT.getNode()) {
829 JITEvent_EmittedFunctionDetails::LineStart NextLine;
830 NextLine.Address = getCurrentPCValue();
831 NextLine.Loc = DL;
832 EmissionDetails.LineStarts.push_back(NextLine);
833 }
834
835 PrevDLT = CurDLT;
836 }
837 }
823 if (DL.isUnknown()) return;
824 if (!BeforePrintingInsn) return;
825
826 // FIXME: This is horribly inefficient.
827 DILocation CurDLT(DL.getAsMDNode(CurFn->getContext()));
828
829 if (CurDLT.getScope().getNode() != 0 && PrevDLT.getNode() !=CurDLT.getNode()){
830 JITEvent_EmittedFunctionDetails::LineStart NextLine;
831 NextLine.Address = getCurrentPCValue();
832 NextLine.Loc = DL;
833 EmissionDetails.LineStarts.push_back(NextLine);
834 }
835
836 PrevDLT = CurDLT;
838837 }
839838
840839 static unsigned GetConstantPoolSizeInBytes(MachineConstantPool *MCP,
255255 ///
256256 void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF,
257257 const DebugLoc &DL, bool IsInBeginFunction) {
258 if (! EmitDebugDirectives) return;
259 assert (! DL.isUnknown() && "can't change to invalid debug loc");
260
261 DILocation Loc = MF.getDILocation(DL);
262 MDNode *CU = Loc.getScope().getNode();
263 unsigned line = Loc.getLineNumber();
264
265 SwitchToCU(CU);
266 SwitchToLine(line, IsInBeginFunction);
258 if (!EmitDebugDirectives) return;
259 assert(!DL.isUnknown() && "can't change to invalid debug loc");
260
261 SwitchToCU(DL.getScope(MF.getFunction()->getContext()));
262 SwitchToLine(DL.getLine(), IsInBeginFunction);
267263 }
268264
269265 /// SwitchToLine - Emit line directive for a new line.
1818
1919 namespace llvm {
2020 class MachineFunction;
21 class DebugLoc;
21 class NewDebugLoc; typedef NewDebugLoc DebugLoc;
2222 namespace PIC16Dbg {
2323 enum VarType {
2424 T_NULL,