From 00d9639c248b226225484bfd60cf0d694c353c38 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 29 Jan 2016 00:13:28 +0000 Subject: Revert "[CodeView] Use assembler directives for line tables" This reverts commit r259117. The LineInfo constructor is defined in the codeview library and we have to link against it now. Doing that isn't trivial, so reverting for now. llvm-svn: 259126 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 70 +++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 18 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h') diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index 77b5ed39c1f..4294b4fd694 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -37,38 +37,72 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler { // to the end of the function. struct FunctionInfo { DebugLoc LastLoc; - MCSymbol *End = nullptr; - unsigned FuncId = 0; - unsigned LastFileId; - bool HaveLineInfo = false; + SmallVector Instrs; + MCSymbol *End; + FunctionInfo() : End(nullptr) {} }; FunctionInfo *CurFn; - unsigned NextFuncId = 0; - - /// Remember some debug info about each function. Keep it in a stable order to - /// emit at the end of the TU. - MapVector FnDebugInfo; - - /// Map from DIFile to .cv_file id. - DenseMap FileIdMap; + typedef DenseMap FnDebugInfoTy; + FnDebugInfoTy FnDebugInfo; + // Store the functions we've visited in a vector so we can maintain a stable + // order while emitting subsections. + SmallVector VisitedFunctions; + + DenseMap LabelsAndLocs; + + // FileNameRegistry - Manages filenames observed while generating debug info + // by filtering out duplicates and bookkeeping the offsets in the string + // table to be generated. + struct FileNameRegistryTy { + SmallVector Filenames; + struct PerFileInfo { + size_t FilenameID, StartOffset; + }; + StringMap Infos; + + // The offset in the string table where we'll write the next unique + // filename. + size_t LastOffset; + + FileNameRegistryTy() { + clear(); + } + + // Add Filename to the registry, if it was not observed before. + size_t add(StringRef Filename) { + size_t OldSize = Infos.size(); + bool Inserted; + StringMap::iterator It; + std::tie(It, Inserted) = Infos.insert( + std::make_pair(Filename, PerFileInfo{OldSize, LastOffset})); + if (Inserted) { + LastOffset += Filename.size() + 1; + Filenames.push_back(Filename); + } + return It->second.FilenameID; + } + + void clear() { + LastOffset = 1; + Infos.clear(); + Filenames.clear(); + } + } FileNameRegistry; typedef std::map FileToFilepathMapTy; FileToFilepathMapTy FileToFilepathMap; StringRef getFullFilepath(const DIFile *S); - unsigned maybeRecordFile(const DIFile *F); - void maybeRecordLocation(DebugLoc DL, const MachineFunction *MF); void clear() { assert(CurFn == nullptr); - FileIdMap.clear(); - FnDebugInfo.clear(); - FileToFilepathMap.clear(); + FileNameRegistry.clear(); + LabelsAndLocs.clear(); } - void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI); + void emitDebugInfoForFunction(const Function *GV); public: CodeViewDebug(AsmPrinter *Asm); -- cgit v1.2.3