From b2efb853f00d45b1c8d57f92acd0028fbdeffda6 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Wed, 4 Jan 2006 22:28:25 +0000 Subject: Applied some recommend changes from sabre. The dominate one beginning "let the pass manager do it's thing." Fixes crash when compiling -g files and suppresses dwarf statements if no debug info is present. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25100 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineDebugInfo.cpp | 106 ++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 64 deletions(-) (limited to 'lib/CodeGen/MachineDebugInfo.cpp') diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index fc88b8ca00..d2a5fd5eb3 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -18,74 +18,52 @@ using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. namespace { - RegisterPass X("machinedebuginfo", "Debug Information", - PassInfo::Analysis | PassInfo::Optimization); + RegisterPass X("machinedebuginfo", "Debug Information"); } - -namespace llvm { - - /// DebugInfo - Keep track of debug information for the function. - /// - // FIXME - making it global until we can find a proper place to hang it from. - MachineDebugInfo *DebugInfo; - - // FIXME - temporary hack until we can find a place to hand debug info from. - ModulePass *createDebugInfoPass() { - if (!DebugInfo) DebugInfo = new MachineDebugInfo(); - return (ModulePass *)DebugInfo; - } - /// getDebugInfo - Returns the DebugInfo. - MachineDebugInfo &getMachineDebugInfo() { - assert(DebugInfo && "DebugInfo pass not created"); - return *DebugInfo; - } - - /// doInitialization - Initialize the debug state for a new module. - /// - bool MachineDebugInfo::doInitialization() { - return true; - } +/// doInitialization - Initialize the debug state for a new module. +/// +bool MachineDebugInfo::doInitialization() { + return false; +} - /// doFinalization - Tear down the debug state after completion of a module. - /// - bool MachineDebugInfo::doFinalization() { - - return true; - } +/// doFinalization - Tear down the debug state after completion of a module. +/// +bool MachineDebugInfo::doFinalization() { + return false; +} - /// RecordSource - Register a source file with debug info. Returns an id. - /// - unsigned MachineDebugInfo::RecordSource(std::string fname, - std::string dirname) { - // Compose a key - std::string path = dirname + "/" + fname; - // Check if the source file is already recorded - StrIntMapIter SMI = SourceMap.find(path); - // If already there return existing id - if (SMI != SourceMap.end()) return SMI->second; - // Bump up the count - ++SourceCount; - // Record the count - SourceMap[path] = SourceCount; - // Return id - return SourceCount; - } +/// getUniqueSourceID - Register a source file with debug info. Returns an id. +/// +unsigned MachineDebugInfo::getUniqueSourceID(const std::string &fname, + const std::string &dirname) { + // Compose a key + const std::string path = dirname + "/" + fname; + // Check if the source file is already recorded + std::map::iterator + SMI = SourceMap.lower_bound(path); + // If already there return existing id + if (SMI != SourceMap.end() && SMI->first == path) return SMI->second; + // Bump up the count + ++SourceCount; + // Record the count + SourceMap.insert(SMI, std::make_pair(path, SourceCount)); + // Return id + return SourceCount; +} - /// getSourceFiles - Return a vector of files. Vector index + 1 equals id. - /// - std::vector MachineDebugInfo::getSourceFiles() { - std::vector Sources(SourceCount); - - for (StrIntMapIter SMI = SourceMap.begin(), E = SourceMap.end(); SMI != E; - SMI++) { - unsigned Index = SMI->second - 1; - std::string Path = SMI->first; - Sources[Index] = Path; - } - return Sources; +/// getSourceFiles - Return a vector of files. Vector index + 1 equals id. +/// +std::vector MachineDebugInfo::getSourceFiles() const { + std::vector Sources(SourceCount); + + for (std::map::const_iterator SMI = SourceMap.begin(), + E = SourceMap.end(); + SMI != E; SMI++) { + unsigned Index = SMI->second - 1; + const std::string &Path = SMI->first; + Sources[Index] = Path; } - - -}; + return Sources; +} -- cgit v1.2.3-18-g5258