Author: djg Date: Mon Oct 1 17:40:20 2007 New Revision: 42506 URL: http://llvm.org/viewvc/llvm-project?rev=42506&view=rev Log: Move the code that emits the .file directives so that it runs after the SourceFiles list is fully filled in so that it sees all of the files.
Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=42506&r1=42505&r2=42506&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Mon Oct 1 17:40:20 2007 @@ -1971,19 +1971,6 @@ if (didInitial) return; didInitial = true; - // Print out .file directives to specify files for .loc directives. - if (TAI->hasDotLocAndDotFile()) { - const UniqueVector<SourceFileInfo> &SourceFiles = MMI->getSourceFiles(); - const UniqueVector<std::string> &Directories = MMI->getDirectories(); - for (unsigned i = 1, e = SourceFiles.size(); i <= e; ++i) { - sys::Path FullPath(Directories[SourceFiles[i].getDirectoryID()]); - bool AppendOk = FullPath.appendComponent(SourceFiles[i].getName()); - assert(AppendOk && "Could not append filename to directory!"); - Asm->EmitFile(i, FullPath.toString()); - Asm->EOL(); - } - } - // Dwarf sections base addresses. if (TAI->doesDwarfRequireFrameSection()) { Asm->SwitchToDataSection(TAI->getDwarfFrameSection()); @@ -2626,9 +2613,6 @@ MMI = mmi; shouldEmit = true; - // Emit initial sections - EmitInitial(); - // Create all the compile unit DIEs. ConstructCompileUnitDIEs(); @@ -2640,6 +2624,23 @@ // Prime section data. SectionMap.insert(TAI->getTextSection()); + + // Print out .file directives to specify files for .loc directives. These + // are printed out early so that they precede any .loc directives. + if (TAI->hasDotLocAndDotFile()) { + const UniqueVector<SourceFileInfo> &SourceFiles = MMI->getSourceFiles(); + const UniqueVector<std::string> &Directories = MMI->getDirectories(); + for (unsigned i = 1, e = SourceFiles.size(); i <= e; ++i) { + sys::Path FullPath(Directories[SourceFiles[i].getDirectoryID()]); + bool AppendOk = FullPath.appendComponent(SourceFiles[i].getName()); + assert(AppendOk && "Could not append filename to directory!"); + Asm->EmitFile(i, FullPath.toString()); + Asm->EOL(); + } + } + + // Emit initial sections + EmitInitial(); } } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits