From 2c0a4fe4e29b4323fa24303068d4a204a51d33c1 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 3 Feb 2009 22:49:58 +0000 Subject: [PATCH] Add getDebugLocTuple to retrieve the DebugLocTuple for a given DebugLoc object. llvm-svn: 63676 --- llvm/include/llvm/CodeGen/MachineFunction.h | 7 +++++-- llvm/lib/CodeGen/MachineFunction.cpp | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 6abedb50b3c2..b1536a8f7525 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -313,9 +313,12 @@ public: // /// 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. + /// source file, line, and column. If none currently exists, create a new + /// DebugLocTuple, and insert it into the DebugIdMap. unsigned getOrCreateDebugLocID(unsigned Src, unsigned Line, unsigned Col); + + /// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object. + const DebugLocTuple &getDebugLocTuple(DebugLoc DL); }; //===--------------------------------------------------------------------===// diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 434034b888f0..fc9aa843e788 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -380,11 +380,11 @@ MachineFunction& MachineFunction::get(const Function *F) } /// 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. +/// source file, line, and column. If none currently exists, create a new +/// DebugLocTuple, and insert it into the DebugIdMap. unsigned MachineFunction::getOrCreateDebugLocID(unsigned Src, unsigned Line, unsigned Col) { - struct DebugLocTuple Tuple(Src, Line, Col); + DebugLocTuple Tuple(Src, Line, Col); DenseMap::iterator II = DebugLocInfo.DebugIdMap.find(Tuple); if (II != DebugLocInfo.DebugIdMap.end()) @@ -396,6 +396,14 @@ unsigned MachineFunction::getOrCreateDebugLocID(unsigned Src, unsigned Line, return Id; } +/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object. +const DebugLocTuple &MachineFunction::getDebugLocTuple(DebugLoc DL) { + unsigned Idx; + assert(Idx < DebugLocInfo.DebugLocations.size() && + "Invalid index into debug locations!"); + return DebugLocInfo.DebugLocations[Idx]; +} + //===----------------------------------------------------------------------===// // MachineFrameInfo implementation //===----------------------------------------------------------------------===//