From a329a133d66a86249a3b1ce8025a88f4c0b197c4 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Wed, 13 Nov 2013 23:43:19 +0100 Subject: Simplify acquisition of debug informtion for instruction info with newer LLVM versions With newer LLVM versions (starting with LLVM 2.7) debug information are directly associated as meta data with each instruction. Therefore, debug information can be acquired directly from each instruction. --- lib/Module/InstructionInfoTable.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index 301db1ff..4285c6b0 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -111,6 +111,26 @@ InstructionInfoTable::InstructionInfoTable(Module *m) const std::string *initialFile = &dummyString; unsigned initialLine = 0; +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) + for (inst_iterator it = inst_begin(fnIt), ie = inst_end(fnIt); it != ie; + ++it) { + const std::string *initialFile = &dummyString; + unsigned initialLine = 0; + Instruction *instr = &*it; + unsigned assemblyLine = 0; + + std::map::const_iterator ltit = + lineTable.find(instr); + if (ltit!=lineTable.end()) + assemblyLine = ltit->second; + getInstructionDebugInfo(instr, initialFile, initialLine); + infos.insert(std::make_pair(instr, + InstructionInfo(id++, + *initialFile, + initialLine, + assemblyLine))); + } +#else // It may be better to look for the closest stoppoint to the entry // following the CFG, but it is not clear that it ever matters in // practice. @@ -118,7 +138,7 @@ InstructionInfoTable::InstructionInfoTable(Module *m) it != ie; ++it) if (getInstructionDebugInfo(&*it, initialFile, initialLine)) break; - + typedef std::map > sourceinfo_ty; sourceinfo_ty sourceInfo; @@ -167,6 +187,7 @@ InstructionInfoTable::InstructionInfoTable(Module *m) } } while (!worklist.empty()); } +#endif } } -- cgit 1.4.1