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
Event Timeline
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
506 | Why did you not choose to make this part of the ChecksumInfo struct? | |
521 | It's used for both MDStrings and StringRefs. | |
587–588 | Would it make sense to move these into ChecksumInfo too? | |
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | ||
177 | Why do we have/need two enums to express the same thing? Are the values different? |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
506 | 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. | |
587–588 | 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 | 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 | 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 | ||
17 | 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 | 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 | ||
17 | You are right, I will minimize the test case. |
These should be /// Doxygen comments.