diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h index bd95fe24d05..1cb785c73fd 100644 --- a/include/llvm/CodeGen/DwarfWriter.h +++ b/include/llvm/CodeGen/DwarfWriter.h @@ -151,7 +151,7 @@ private: /// SectionSourceLines - Tracks line numbers per text section. /// - std::vector > SectionSourceLines; + std::vector > SectionSourceLines; public: diff --git a/include/llvm/CodeGen/MachineDebugInfo.h b/include/llvm/CodeGen/MachineDebugInfo.h index c559b6b66d7..a031ad0c6f6 100644 --- a/include/llvm/CodeGen/MachineDebugInfo.h +++ b/include/llvm/CodeGen/MachineDebugInfo.h @@ -967,7 +967,7 @@ private: UniqueVector SourceFiles; // Lines - List of of source line correspondence. - std::vector Lines; + std::vector Lines; // LabelID - Current number assigned to unique label numbers. unsigned LabelID; @@ -1049,10 +1049,15 @@ public: /// getSourceLines - Return a vector of source lines. /// - std::vector &getSourceLines() { + const std::vector &getSourceLines() const { return Lines; } + // FIXME: nuke this. + void ClearLineInfo() { + Lines.clear(); + } + /// SetupCompileUnits - Set up the unique vector of compile units. /// void SetupCompileUnits(Module &M); diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index 1d08d07a8a3..dc59b810682 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -2178,7 +2178,7 @@ void DwarfWriter::EmitDebugLines() const { // A sequence for each text section. for (unsigned j = 0, M = SectionSourceLines.size(); j < M; ++j) { // Isolate current sections line info. - const std::vector &LineInfos = SectionSourceLines[j]; + const std::vector &LineInfos = SectionSourceLines[j]; if (DwarfVerbose) { O << "\t" @@ -2193,40 +2193,40 @@ void DwarfWriter::EmitDebugLines() const { // Construct rows of the address, source, line, column matrix. for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) { - SourceLineInfo *LineInfo = LineInfos[i]; + const SourceLineInfo &LineInfo = LineInfos[i]; if (DwarfVerbose) { - unsigned SourceID = LineInfo->getSourceID(); + unsigned SourceID = LineInfo.getSourceID(); const SourceFileInfo &SourceFile = SourceFiles[SourceID]; unsigned DirectoryID = SourceFile.getDirectoryID(); O << "\t" << TAI->getCommentString() << " " << Directories[DirectoryID] << SourceFile.getName() << ":" - << LineInfo->getLine() << "\n"; + << LineInfo.getLine() << "\n"; } // Define the line address. EmitInt8(0); EOL("Extended Op"); EmitInt8(4 + 1); EOL("Op size"); EmitInt8(DW_LNE_set_address); EOL("DW_LNE_set_address"); - EmitReference("loc", LineInfo->getLabelID()); EOL("Location label"); + EmitReference("loc", LineInfo.getLabelID()); EOL("Location label"); // If change of source, then switch to the new source. - if (Source != LineInfo->getSourceID()) { - Source = LineInfo->getSourceID(); + if (Source != LineInfo.getSourceID()) { + Source = LineInfo.getSourceID(); EmitInt8(DW_LNS_set_file); EOL("DW_LNS_set_file"); EmitULEB128Bytes(Source); EOL("New Source"); } // If change of line. - if (Line != LineInfo->getLine()) { + if (Line != LineInfo.getLine()) { // Determine offset. - int Offset = LineInfo->getLine() - Line; + int Offset = LineInfo.getLine() - Line; int Delta = Offset - MinLineDelta; // Update line. - Line = LineInfo->getLine(); + Line = LineInfo.getLine(); // If delta is small enough and in range... if (Delta >= 0 && Delta < (MaxLineDelta - 1)) { @@ -2635,13 +2635,13 @@ void DwarfWriter::EndFunction() { EmitLabel("func_end", SubprogramCount); // Get function line info. - std::vector &LineInfos = DebugInfo->getSourceLines(); + const std::vector &LineInfos = DebugInfo->getSourceLines(); if (!LineInfos.empty()) { // Get section line info. unsigned ID = SectionMap.insert(Asm->CurrentSection); if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID); - std::vector &SectionLineInfos =SectionSourceLines[ID-1]; + std::vector &SectionLineInfos = SectionSourceLines[ID-1]; // Append the function info to section info. SectionLineInfos.insert(SectionLineInfos.end(), LineInfos.begin(), LineInfos.end()); @@ -2654,7 +2654,8 @@ void DwarfWriter::EndFunction() { EmitFunctionDebugFrame(); // Reset the line numbers for the next function. - LineInfos.clear(); + // FIXME: move this to release memory of the debuginfo object. + DebugInfo->ClearLineInfo(); // Clear function debug information. DebugInfo->EndFunction(); diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index c87928f44a4..a227589e1e8 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -1538,7 +1538,7 @@ MachineDebugInfo::getGlobalVariablesUsing(Module &M, unsigned MachineDebugInfo::RecordLabel(unsigned Line, unsigned Column, unsigned Source) { unsigned ID = NextLabelID(); - Lines.push_back(new SourceLineInfo(Line, Column, Source, ID)); + Lines.push_back(SourceLineInfo(Line, Column, Source, ID)); return ID; }