[llvm] r316018 - Fix signed overflow detected by ubsan

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 11:33:15 PDT 2017


Author: vitalybuka
Date: Tue Oct 17 11:33:15 2017
New Revision: 316018

URL: http://llvm.org/viewvc/llvm-project?rev=316018&view=rev
Log:
Fix signed overflow detected by ubsan

This overflow does not affect algorithm, so just suppress it.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=316018&r1=316017&r2=316018&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Oct 17 11:33:15 2017
@@ -5439,7 +5439,7 @@ static bool ReduceSwitchRange(SwitchInst
   // First, transform the values such that they start at zero and ascend.
   int64_t Base = Values[0];
   for (auto &V : Values)
-    V -= Base;
+    V -= (uint64_t)(Base);
 
   // Now we have signed numbers that have been shifted so that, given enough
   // precision, there are no negative values. Since the rest of the transform




More information about the llvm-commits mailing list