diff options
author | modimo <modimo@fb.com> | 2021-12-28 14:48:15 -0800 |
---|---|---|
committer | modimo <modimo@fb.com> | 2021-12-28 15:22:18 -0800 |
commit | ba51d26ec4519f5b31de3acf643264504ea7bc7c (patch) | |
tree | bd5104eccf7808b255b8123b54a05be09b9f3bce /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | 6a6ac3b36fcdb44a5096f2ddab952a1281eb144e (diff) | |
download | llvm-ba51d26ec4519f5b31de3acf643264504ea7bc7c.zip llvm-ba51d26ec4519f5b31de3acf643264504ea7bc7c.tar.gz llvm-ba51d26ec4519f5b31de3acf643264504ea7bc7c.tar.bz2 |
[CodeView] Clamp Frontend version
D43002 introduced a test debug-info-objname.cpp that outputted the current compiler version into CodeView. Internally we appended a date to the patch version and overflowed the 16-bits allocated to that space. This change clamps the Frontend version outputted values to 16-bits like rGd1185fc081ead71a8bf239ff1814f5ff73084c15 did for the Backend version.
Testing:
ninja check-all
newly added tests correctly clamps and no longer asserts when trying to output the field
Reviewed By: aganea
Differential Revision: https://reviews.llvm.org/D116243
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index d621108..ed74d2b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -857,8 +857,10 @@ void CodeViewDebug::emitCompilerInformation() { StringRef CompilerVersion = CU->getProducer(); Version FrontVer = parseVersion(CompilerVersion); OS.AddComment("Frontend version"); - for (int N : FrontVer.Part) + for (int N : FrontVer.Part) { + N = std::min<int>(N, std::numeric_limits<uint16_t>::max()); OS.emitInt16(N); + } // Some Microsoft tools, like Binscope, expect a backend version number of at // least 8.something, so we'll coerce the LLVM version into a form that |