llvm.org GIT mirror llvm / aaeea9e
Refine DebugLoc per review comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63132 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
3 changed file(s) with 22 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
3232 unsigned Idx;
3333
3434 public:
35 DebugLoc() : Idx(~0U) {}
35 DebugLoc() : Idx(~0U) {} // Defaults to invalid.
3636
37 static DebugLoc getNoDebugLoc() { DebugLoc L; L.Idx = 0; return L; }
37 static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = 0; return L; }
3838 static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
3939
40 bool isInvalid() { return Idx == ~0U; }
41 bool isUnknown() { return Idx == 0; }
40 // isInvalid - Return true if the DebugLoc is invalid.
41 bool isInvalid() const { return Idx == ~0U; }
42
43 // isUnknown - Return true if there is no debug info for the SDNode /
44 // MachineInstr.
45 bool isUnknown() const { return Idx == 0; }
4246 };
4347
44 struct DebugLocTupleDenseMapInfo {
48 // Partially specialize DenseMapInfo for DebugLocTyple.
49 template<> struct DenseMapInfo {
4550 static inline DebugLocTuple getEmptyKey() {
4651 return DebugLocTuple(~0U, ~0U, ~0U);
4752 }
6267 static bool isPod() { return true; }
6368 };
6469
65 typedef DenseMap
66 DebugIdMapType;
67
6870 /// DebugLocTracker - This class tracks debug location information.
6971 ///
7072 struct DebugLocTracker {
7476
7577 // DebugIdsMap - This maps DebugLocTuple's to indices into
7678 // DebugLocations vector.
77 DebugIdMapType DebugIdMap;
79 DenseMap DebugIdMap;
7880
7981 DebugLocTracker() {}
8082
310310 // Debug location.
311311 //
312312
313 /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
314 /// source file, line, and column. It may add a new filename and / or
315 /// a new DebugLocTuple.
316 unsigned lookUpDebugLocId(unsigned Src, unsigned Line, unsigned Col);
313 /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
314 /// source file, line, and column. If none currently exists, create add a new
315 /// new DebugLocTuple and insert it into the DebugIdMap.
316 unsigned getOrCreateDebugLocID(unsigned Src, unsigned Line, unsigned Col);
317317 };
318318
319319 //===--------------------------------------------------------------------===//
377377 return *mc;
378378 }
379379
380 /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
381 /// source file, line, and column. It may add a new filename and / or
382 /// a new DebugLocTuple.
383 unsigned MachineFunction::lookUpDebugLocId(unsigned Src, unsigned Line,
384 unsigned Col) {
380 /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
381 /// source file, line, and column. If none currently exists, create add a new
382 /// new DebugLocTuple and insert it into the DebugIdMap.
383 unsigned MachineFunction::getOrCreateDebugLocID(unsigned Src, unsigned Line,
384 unsigned Col) {
385385 struct DebugLocTuple Tuple(Src, Line, Col);
386 DebugIdMapType::iterator II = DebugLocInfo.DebugIdMap.find(Tuple);
386 DenseMap::iterator II
387 = DebugLocInfo.DebugIdMap.find(Tuple);
387388 if (II != DebugLocInfo.DebugIdMap.end())
388389 return II->second;
389390 // Add a new tuple.