aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-01-26 07:41:49 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-01-26 07:41:49 +0000
commitd0adbb5b7da2d1238fdf1a30734a001a0103aab0 (patch)
tree2a019e89810a2aad71780c5280dbf187b8f36285 /lib
parentd5362986da35310b68452f4437dffad071b7fe47 (diff)
downloadexternal_llvm-d0adbb5b7da2d1238fdf1a30734a001a0103aab0.zip
external_llvm-d0adbb5b7da2d1238fdf1a30734a001a0103aab0.tar.gz
external_llvm-d0adbb5b7da2d1238fdf1a30734a001a0103aab0.tar.bz2
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
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/MachineFunction.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 8bae7bb..0d442af 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/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
//===----------------------------------------------------------------------===//