The checksums had already been placed in the IR, this patch allows
MCCodeView to actually write it out to an MCStreamer.
Details
Diff Detail
- Build Status
Buildable 10163 Build 10163: arc lint + arc unit
Event Timeline
Try to be more careful so as not to submit testing code / comments etc in uploaded patches. Reasons like this are why I prefer using a debugger instead of printf debugging :)
llvm/include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
476–481 | If you're going to make it an enum class, then it doesn't need the CSK prefix in the name, since you have to write ChecksumKind anyway. I wouldn't suggest churning the code to change the names everywhere it's used, so instead maybe just leave this as a regular enum. It's already scoped to DIFile anyway, so there's no risk of namespace pollution. | |
llvm/include/llvm/MC/MCCodeView.h | ||
305–313 | Any reason this isn't just: struct FileInfo { StringRef Name; StringRef Checksum; ChecksumKind Kind; }; SmallVector<FileInfo> Files; having a StringMap seems unnecessary if we're already iterating a linear container anyway | |
llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp | ||
53 | Delete | |
llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp | ||
32 | Delete | |
39 | Delete | |
45 | Delete | |
llvm/lib/MC/MCCodeView.cpp | ||
273–285 | What is this? A bunch of code commented out, and then emitting a bunch of magic numbers? | |
llvm/tools/llvm-readobj/COFFDumper.cpp | ||
935 | Delete | |
937 | Delete | |
1104 | Delete | |
1110 | Delete |
llvm/lib/MC/MCCodeView.cpp | ||
---|---|---|
550–560 | We shouldn't assume all DIFiles have MD5 checksums, we'll need some way to know the filechecksum table offset. We should probably implement this FIXME: // FIXME: We should store the string table offset of the filename, rather than // the filename itself for efficiency. Filename = addToStringTable(Filename); Filenames[Idx] = Filename; We should do that by making FIlenames a vector of two integers: the offset of the file in the file checksum table, and the offset of the filename in the string table. All the places where we do 8 * (FileId - 1) we would rewrite to use Filenames[FileId - 1].ChecksumTableOffset. |
llvm/include/llvm/MC/MCCodeView.h | ||
---|---|---|
290 | remove | |
304 | Just one comment says: Array storing file information. Each tuple contains the string table offset, a symbol representing the file table offset, and a set flag. | |
309 | remove | |
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | ||
702–704 | remove this comment | |
704 | remove junk here too | |
llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp | ||
53 | remove | |
llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp | ||
32 | remove | |
39 | remove | |
45 | remove |
llvm/lib/MC/MCCodeView.cpp | ||
---|---|---|
49 | remove | |
64 | remove comment | |
141 | combine this all into one line | |
142 | Don't reassign to S and just directly use Ret.first | |
159 | add a comment explaining this function | |
160 | remove | |
166 | remove spaces here | |
172 | remove these | |
178 | +=4 for the string table offset | |
181 | +1 for size, +1 for kind, +2 to align (maybe just replace that with alignTo for clarity) | |
184 | remove logging, more comments to explain offset | |
259 | add comment explaining that, since the checksum section has been emitted, we can assume the offsets have been finalized so we can assign them. | |
270 | update this comment | |
274 | remove these | |
284 | yes remove this | |
296 | add comment to explain, how it needs to use a MCFixup provided by EmitValueImpl | |
308 | remove | |
311 | create a temporary symbol to hold the offset once it is calculated | |
350 | remove | |
365 | a | |
504 | r | |
550 | change this comment | |
llvm/lib/MC/MCObjectStreamer.cpp | ||
144 | r | |
llvm/lib/MC/MCParser/AsmParser.cpp | ||
3464 | should be lower case for consistency | |
llvm/lib/MC/WinCOFFObjectWriter.cpp | ||
725 | r | |
llvm/tools/llvm-readobj/COFFDumper.cpp | ||
910 | r these | |
1020 | r | |
1106 | not needed |
Make this entire thing easier to follow and understand.
llvm/lib/MC/MCCodeView.cpp | ||
---|---|---|
61 | This is confusing to read, make it more intuitive |
Why do we have to add placeholders for the checksum offsets? Aren't they just added in order, one after another?
Actually, the implementation of addFile hasn't assumed it is done in order, and you can actually add random fileNo's whenever you want. Therefore, we shouldn't assume they are always done in order, and we should allow for the case where we don't yet know the checksum offset.
llvm/include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
476–481 | Unfortunately I need the actual enum values to correspond exactly to the checksum types flag integer values actually present in the codeview section, hence the strongly typed enum class. This is important because I will now be emitting the ChecksumKind as assembly directives as well as directly into the binary. | |
llvm/include/llvm/MC/MCCodeView.h | ||
305–313 | Yes, combined all this info into one vector. It's still useful to have a StringMap because we want to check if a filename is already used before making a new entry. |
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | ||
---|---|---|
688 | Update this FIXME to say that we do provide checksum file info, and what VS uses this for. |
llvm/lib/MC/MCCodeView.cpp | ||
---|---|---|
174 | I don't think you want to do this, this leaks the internal MCSymbol (file1, etc) to the assembler. Nothing in the assembly defines file1, so the assembly isn't very readable. | |
llvm/test/DebugInfo/COFF/inlining.ll | ||
52 | What I had in mind was that we'd add a directive like .cv_filechecksum_offset <fileid> and MCCodeView.cpp would internally implement it without leaking any labels to the caller. We could use a label difference of two symbols to implement the offset computation, but any symbols shouldn't leak out to the assembler. |
llvm/include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
476–481 | If you need the enums to have specific values, e.g. because those values end up in the object file (hard to tell here but I think that's what you are saying), you should set the enum values explicitly. This documents the exact values you need (even if they happen to be sequential at the moment). Making it an enum class doesn't get you that. | |
llvm/lib/IR/DebugInfoMetadata.cpp | ||
357–359 | If you require exact correspondence between an enum and some array of strings, we usually do that with a .def file and macros. See for example Dwarf.def. As it is, the association between this array and the ChecksumKind values is implied rather than explicit. Safer to be explicit. |
llvm/lib/MC/MCCodeView.cpp | ||
---|---|---|
71 | Use MCContext::createTempSymbol to make sure these don't show up in the .obj symbol table. |
llvm/include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
476–481 | Remove enum class to explicitly define values. | |
llvm/lib/IR/DebugInfoMetadata.cpp | ||
357–359 | Okay this should probably be addressed in another patch as this patch did not introduce the array. | |
llvm/lib/MC/MCCodeView.cpp | ||
174 | Instead of emitting the symbol, we will emit the .cv_filechecksumoffset <fileno> directive. |
A few minor commentary points; nothing huge. I've been looking at this mainly with the thought of having to do something similar for DWARF 5 eventually, but it seems likely there won't be a lot to leverage as CodeView and DWARF appear to associate the hashes with files pretty differently. Oh well.
llvm/include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
476–481 | And maybe a comment that these end up in the object file, so some well-meaning person doesn't come a long later and remove the "unnecessary" explicit values. | |
llvm/include/llvm/MC/MCStreamer.h | ||
735–736 | As long as you're changing the comment anyway, please remove the \brief. | |
785 | Remove \brief. |
llvm/test/DebugInfo/COFF/inlining.ll | ||
---|---|---|
52 | implemented as such |
Thanks, looks good!
llvm/include/llvm/MC/MCCodeView.h | ||
---|---|---|
307–308 | Generally, if the comment describing the variable doesn't fit on one line, consider moving it before the variable. Then we won't end up with this awkard split after the *. |
If you're going to make it an enum class, then it doesn't need the CSK prefix in the name, since you have to write ChecksumKind anyway. I wouldn't suggest churning the code to change the names everywhere it's used, so instead maybe just leave this as a regular enum. It's already scoped to DIFile anyway, so there's no risk of namespace pollution.