diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-01-26 07:41:49 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-01-26 07:41:49 +0000 |
commit | b5706c45fa2ec5e9e35922b68da34c7755f59ac8 (patch) | |
tree | 343f50ff0adedac7100eaf88f3f9674864f45d80 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | fd0ab1232761f44cbc17d1176f1d77da7b87ca50 (diff) | |
download | bcm5719-llvm-b5706c45fa2ec5e9e35922b68da34c7755f59ac8.tar.gz bcm5719-llvm-b5706c45fa2ec5e9e35922b68da34c7755f59ac8.zip |
Add data structure to define and track debug location during codegen.
llvm-svn: 63008
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 8bae7bbb92c..0d442af7eda 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -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 //===----------------------------------------------------------------------===// |