Add data structure to define and track debug location during codegen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2009-01-26 07:41:49 +00:00
parent d5362986da
commit d0adbb5b7d
3 changed files with 150 additions and 1 deletions

View File

@ -378,6 +378,33 @@ MachineFunction& MachineFunction::get(const Function *F)
return *mc;
}
/// lookUpDebugLocId - Look up the DebugLocTuple index with the given
/// filename, line, and column. It may add a new filename and / or
/// a new DebugLocTuple.
unsigned MachineFunction::lookUpDebugLocId(const char *Filename, unsigned Line,
unsigned Col) {
unsigned FileId;
StringMap<unsigned>::iterator I =
DebugLocInfo.DebugFilenamesMap.find(Filename);
if (I != DebugLocInfo.DebugFilenamesMap.end())
FileId = I->second;
else {
// Add a new filename.
FileId = DebugLocInfo.NumFilenames++;
DebugLocInfo.DebugFilenames.push_back(Filename);
DebugLocInfo.DebugFilenamesMap[Filename] = FileId;
}
struct DebugLocTuple Tuple(FileId, Line, Col);
DebugIdMapType::iterator II = DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
return II->second;
// Add a new tuple.
DebugLocInfo.DebugLocations.push_back(Tuple);
DebugLocInfo.DebugIdMap[Tuple] = DebugLocInfo.NumDebugLocations;
return DebugLocInfo.NumDebugLocations++;
}
//===----------------------------------------------------------------------===//
// MachineFrameInfo implementation
//===----------------------------------------------------------------------===//