llvm.org GIT mirror llvm / c4b1abd
Actually source file has already been uniquified into an id during isel. Eliminate the StringMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63009 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
3 changed file(s) with 12 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
1313 #define LLVM_CODEGEN_DEBUGLOC_H
1414
1515 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/StringMap.h"
1716 #include
1817
1918 namespace llvm {
2120 /// DebugLocTuple - Debug location tuple of filename id, line and column.
2221 ///
2322 struct DebugLocTuple {
24 unsigned FileId, Line, Col;
23 unsigned Src, Line, Col;
2524
26 DebugLocTuple(unsigned fi, unsigned l, unsigned c)
27 : FileId(fi), Line(l), Col(c) {};
25 DebugLocTuple(unsigned s, unsigned l, unsigned c)
26 : Src(s), Line(l), Col(c) {};
2827 };
2928
3029 /// DebugLoc - Debug location id. This is carried by SDNode and
5049 return DebugLocTuple(~1U, ~1U, ~1U);
5150 }
5251 static unsigned getHashValue(const DebugLocTuple &Val) {
53 return DenseMapInfo::getHashValue(Val.FileId) ^
52 return DenseMapInfo::getHashValue(Val.Src) ^
5453 DenseMapInfo::getHashValue(Val.Line) ^
5554 DenseMapInfo::getHashValue(Val.Col);
5655 }
5756 static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
58 return LHS.FileId == RHS.FileId &&
57 return LHS.Src == RHS.Src &&
5958 LHS.Line == RHS.Line &&
60 LHS.Col == RHS.Col;
59 LHS.Col == RHS.Col;
6160 }
6261
6362 static bool isPod() { return true; }
6968 /// DebugLocTracker - This class tracks debug location information.
7069 ///
7170 struct DebugLocTracker {
72 // NumFilenames - Size of the DebugFilenames vector.
73 //
74 unsigned NumFilenames;
75
76 // DebugFilenames - A vector of unique file names.
77 //
78 std::vector DebugFilenames;
79
80 // DebugFilenamesMap - File name to DebugFilenames index map.
81 //
82 StringMap DebugFilenamesMap;
83
8471 // NumDebugLocations - Size of the DebugLocations vector.
8572 unsigned NumDebugLocations;
8673
9279 // DebugLocations vector.
9380 DebugIdMapType DebugIdMap;
9481
95 DebugLocTracker() : NumFilenames(0), NumDebugLocations(0) {}
82 DebugLocTracker() : NumDebugLocations(0) {}
9683
9784 ~DebugLocTracker() {
98 NumFilenames = 0;
99 DebugFilenames.clear();
100 DebugFilenamesMap.clear();
10185 DebugLocations.clear();
10286 DebugIdMap.clear();
10387 }
311311 //
312312
313313 /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
314 /// filename, line, and column. It may add a new filename and / or
314 /// source file, line, and column. It may add a new filename and / or
315315 /// a new DebugLocTuple.
316 unsigned lookUpDebugLocId(const char *Filename, unsigned Line, unsigned Col);
316 unsigned lookUpDebugLocId(unsigned Src, unsigned Line, unsigned Col);
317317 };
318318
319319 //===--------------------------------------------------------------------===//
378378 }
379379
380380 /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
381 /// filename, line, and column. It may add a new filename and / or
381 /// source file, line, and column. It may add a new filename and / or
382382 /// a new DebugLocTuple.
383 unsigned MachineFunction::lookUpDebugLocId(const char *Filename, unsigned Line,
383 unsigned MachineFunction::lookUpDebugLocId(unsigned Src, unsigned Line,
384384 unsigned Col) {
385 unsigned FileId;
386 StringMap::iterator I =
387 DebugLocInfo.DebugFilenamesMap.find(Filename);
388 if (I != DebugLocInfo.DebugFilenamesMap.end())
389 FileId = I->second;
390 else {
391 // Add a new filename.
392 FileId = DebugLocInfo.NumFilenames++;
393 DebugLocInfo.DebugFilenames.push_back(Filename);
394 DebugLocInfo.DebugFilenamesMap[Filename] = FileId;
395 }
396
397 struct DebugLocTuple Tuple(FileId, Line, Col);
385 struct DebugLocTuple Tuple(Src, Line, Col);
398386 DebugIdMapType::iterator II = DebugLocInfo.DebugIdMap.find(Tuple);
399387 if (II != DebugLocInfo.DebugIdMap.end())
400388 return II->second;