summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-01-28 23:31:52 +0000
committerReid Kleckner <rnk@google.com>2016-01-28 23:31:52 +0000
commitc62e379d22d415a84191c653951fc2dc934c4b72 (patch)
treeea2f564a2f59eac89f4156fd528548a167ee2d75 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
parent581c2b9d4615ca1e8da239b0a193959e067b18d9 (diff)
downloadbcm5719-llvm-c62e379d22d415a84191c653951fc2dc934c4b72.tar.gz
bcm5719-llvm-c62e379d22d415a84191c653951fc2dc934c4b72.zip
[CodeView] Use assembler directives for line tables
Adds a new family of .cv_* directives to LLVM's variant of GAS syntax: - .cv_file: Similar to DWARF .file directives - .cv_loc: Similar to the DWARF .loc directive, but starts with a function id. CodeView line tables are emitted by function instead of by compilation unit, so we needed an extra field to communicate this. Rather than overloading the .loc direction further, we decided it was better to have our own directive. - .cv_stringtable: Emits the codeview string table at the current position. Currently this just contains the filenames as null-terminated strings. - .cv_filechecksums: Emits the file checksum table for all files used with .cv_file so far. There is currently no support for emitting actual checksums, just filenames. This moves the line table emission code down into the assembler. This is in preparation for implementing the inlined call site line table format. The inline line table format encoding algorithm requires knowing the absolute code offsets, so it must run after the assembler has laid out the code. David Majnemer collaborated on this patch. llvm-svn: 259117
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h70
1 files changed, 18 insertions, 52 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
index 4294b4fd694..77b5ed39c1f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -37,72 +37,38 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler {
// to the end of the function.
struct FunctionInfo {
DebugLoc LastLoc;
- SmallVector<MCSymbol *, 10> Instrs;
- MCSymbol *End;
- FunctionInfo() : End(nullptr) {}
+ MCSymbol *End = nullptr;
+ unsigned FuncId = 0;
+ unsigned LastFileId;
+ bool HaveLineInfo = false;
};
FunctionInfo *CurFn;
- typedef DenseMap<const Function *, FunctionInfo> FnDebugInfoTy;
- FnDebugInfoTy FnDebugInfo;
- // Store the functions we've visited in a vector so we can maintain a stable
- // order while emitting subsections.
- SmallVector<const Function *, 10> VisitedFunctions;
-
- DenseMap<MCSymbol *, DebugLoc> 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<StringRef, 10> Filenames;
- struct PerFileInfo {
- size_t FilenameID, StartOffset;
- };
- StringMap<PerFileInfo> 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<PerFileInfo>::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;
+ 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<const Function *, FunctionInfo> FnDebugInfo;
+
+ /// Map from DIFile to .cv_file id.
+ DenseMap<const DIFile *, unsigned> FileIdMap;
typedef std::map<const DIFile *, std::string> 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);
- FileNameRegistry.clear();
- LabelsAndLocs.clear();
+ FileIdMap.clear();
+ FnDebugInfo.clear();
+ FileToFilepathMap.clear();
}
- void emitDebugInfoForFunction(const Function *GV);
+ void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI);
public:
CodeViewDebug(AsmPrinter *Asm);
OpenPOWER on IntegriCloud