[llvm] r282761 - Clamp version number in S_COMPILE3 to avoid overflowing 16-bit field.
Adrian McCarthy via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 13:28:25 PDT 2016
Author: amccarth
Date: Thu Sep 29 15:28:25 2016
New Revision: 282761
URL: http://llvm.org/viewvc/llvm-project?rev=282761&view=rev
Log:
Clamp version number in S_COMPILE3 to avoid overflowing 16-bit field.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=282761&r1=282760&r2=282761&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Sep 29 15:28:25 2016
@@ -614,11 +614,12 @@ void CodeViewDebug::emitCompilerInformat
// 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
// guarantees it'll be big enough without really lying about the version.
- Version BackVer = {{
- 1000 * LLVM_VERSION_MAJOR +
- 10 * LLVM_VERSION_MINOR +
- LLVM_VERSION_PATCH,
- 0, 0, 0 }};
+ int Major = 1000 * LLVM_VERSION_MAJOR +
+ 10 * LLVM_VERSION_MINOR +
+ LLVM_VERSION_PATCH;
+ // Clamp it for builds that use unusually large version numbers.
+ Major = std::min<int>(Major, std::numeric_limits<uint16_t>::max());
+ Version BackVer = {{ Major, 0, 0, 0 }};
OS.AddComment("Backend version");
for (int N = 0; N < 4; ++N)
OS.EmitIntValue(BackVer.Part[N], 2);
More information about the llvm-commits
mailing list