[llvm-commits] [llvm] r63132 - in /llvm/trunk: include/llvm/CodeGen/DebugLoc.h include/llvm/CodeGen/MachineFunction.h lib/CodeGen/MachineFunction.cpp
Evan Cheng
evan.cheng at apple.com
Tue Jan 27 13:15:07 PST 2009
Author: evancheng
Date: Tue Jan 27 15:15:07 2009
New Revision: 63132
URL: http://llvm.org/viewvc/llvm-project?rev=63132&view=rev
Log:
Refine DebugLoc per review comments.
Modified:
llvm/trunk/include/llvm/CodeGen/DebugLoc.h
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
llvm/trunk/lib/CodeGen/MachineFunction.cpp
Modified: llvm/trunk/include/llvm/CodeGen/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DebugLoc.h?rev=63132&r1=63131&r2=63132&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DebugLoc.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DebugLoc.h Tue Jan 27 15:15:07 2009
@@ -33,16 +33,21 @@
unsigned Idx;
public:
- DebugLoc() : Idx(~0U) {}
+ DebugLoc() : Idx(~0U) {} // Defaults to invalid.
- static DebugLoc getNoDebugLoc() { DebugLoc L; L.Idx = 0; return L; }
+ static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = 0; return L; }
static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
- bool isInvalid() { return Idx == ~0U; }
- bool isUnknown() { return Idx == 0; }
+ // isInvalid - Return true if the DebugLoc is invalid.
+ bool isInvalid() const { return Idx == ~0U; }
+
+ // isUnknown - Return true if there is no debug info for the SDNode /
+ // MachineInstr.
+ bool isUnknown() const { return Idx == 0; }
};
- struct DebugLocTupleDenseMapInfo {
+ // Partially specialize DenseMapInfo for DebugLocTyple.
+ template<> struct DenseMapInfo<DebugLocTuple> {
static inline DebugLocTuple getEmptyKey() {
return DebugLocTuple(~0U, ~0U, ~0U);
}
@@ -63,9 +68,6 @@
static bool isPod() { return true; }
};
- typedef DenseMap<DebugLocTuple, unsigned, DebugLocTupleDenseMapInfo>
- DebugIdMapType;
-
/// DebugLocTracker - This class tracks debug location information.
///
struct DebugLocTracker {
@@ -75,7 +77,7 @@
// DebugIdsMap - This maps DebugLocTuple's to indices into
// DebugLocations vector.
- DebugIdMapType DebugIdMap;
+ DenseMap<DebugLocTuple, unsigned> DebugIdMap;
DebugLocTracker() {}
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=63132&r1=63131&r2=63132&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Tue Jan 27 15:15:07 2009
@@ -311,10 +311,10 @@
// Debug location.
//
- /// lookUpDebugLocId - Look up the DebugLocTuple index with the given
- /// source file, line, and column. It may add a new filename and / or
- /// a new DebugLocTuple.
- unsigned lookUpDebugLocId(unsigned Src, unsigned Line, unsigned Col);
+ /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
+ /// source file, line, and column. If none currently exists, create add a new
+ /// new DebugLocTuple and insert it into the DebugIdMap.
+ unsigned getOrCreateDebugLocID(unsigned Src, unsigned Line, unsigned Col);
};
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=63132&r1=63131&r2=63132&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Tue Jan 27 15:15:07 2009
@@ -378,13 +378,14 @@
return *mc;
}
-/// lookUpDebugLocId - Look up the DebugLocTuple index with the given
-/// source file, line, and column. It may add a new filename and / or
-/// a new DebugLocTuple.
-unsigned MachineFunction::lookUpDebugLocId(unsigned Src, unsigned Line,
- unsigned Col) {
+/// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
+/// source file, line, and column. If none currently exists, create add a new
+/// new DebugLocTuple and insert it into the DebugIdMap.
+unsigned MachineFunction::getOrCreateDebugLocID(unsigned Src, unsigned Line,
+ unsigned Col) {
struct DebugLocTuple Tuple(Src, Line, Col);
- DebugIdMapType::iterator II = DebugLocInfo.DebugIdMap.find(Tuple);
+ DenseMap<DebugLocTuple, unsigned>::iterator II
+ = DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
return II->second;
// Add a new tuple.
More information about the llvm-commits
mailing list