Rather than encode the absence of a checksum with a Kind variant, instead put both the kind and value in a struct and wrap it in an Optional.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
502 ↗ | (On Diff #133295) | These should be /// Doxygen comments. |
519 ↗ | (On Diff #133295) | If this is a string, why does this need to be a template? |
lib/Bitcode/Reader/MetadataLoader.cpp | ||
1357 ↗ | (On Diff #133295) | When changing Bitcode, please always add a .bc upgrade test of the old format to test/Bitcode |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
504 ↗ | (On Diff #133295) | Why did you not choose to make this part of the ChecksumInfo struct? |
519 ↗ | (On Diff #133295) | It's used for both MDStrings and StringRefs. |
585 ↗ | (On Diff #133295) | Would it make sense to move these into ChecksumInfo too? |
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | ||
177 ↗ | (On Diff #133295) | Why do we have/need two enums to express the same thing? Are the values different? |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
504 ↗ | (On Diff #133295) | They do not depend on the template parameter, so this saves having two instances of ChecksumKind in the typesystem, namely ChecksumInfo<MDString *>::ChecksumKind and ChecksumInfo<StringRef>::ChecksumKind. |
585 ↗ | (On Diff #133295) | Similar to above, these are static methods which do not depend on the templated string type (and never will), so I chose to leave them outside. Moving them inside just creates multiple, equivalent names for them. |
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | ||
---|---|---|
177 ↗ | (On Diff #133295) | The CodeView enum was already defined, but the previous code simply cast the DIFile::ChecksumKind to unsigned here, as the values happen to line up. This is somewhat fragile, and will only work for one format (why align the DIFile encoding with the CodeView encoding? why not DWARF?). I think being explicit is better here, and so when I had to make a change anyway I added the switch. |
lib/Bitcode/Writer/BitcodeWriter.cpp | ||
---|---|---|
1555 ↗ | (On Diff #133437) | The comment in MetadataLoader claims that the None kind uses 0 as a representation. Why is this condition necessary? |
test/Bitcode/upgrade-dbg-checksum.ll | ||
16 ↗ | (On Diff #133437) | I don't think you need a function or a global at all. An empty module with just two DICompileUnits should be sufficient. |
lib/Bitcode/Writer/BitcodeWriter.cpp | ||
---|---|---|
1555 ↗ | (On Diff #133437) | I'm not sure I understand what you are asking; the old code would have implicitly done the same here, as CSK_None was encoded as 0. In the new code the None variant of the Optional does not have an "encoding", so we have to explicitly encode each part of the struct, even if the Optional is None. In order to retain backwards compatibility, we still reserve null bytes for this purpose, and I documented this in comments on each end and in the ChecksumKind enum. |
test/Bitcode/upgrade-dbg-checksum.ll | ||
16 ↗ | (On Diff #133437) | You are right, I will minimize the test case. |