OSDN Git Service

Fix signed overflow detected by ubsan
authorVitaly Buka <vitalybuka@google.com>
Tue, 17 Oct 2017 18:33:15 +0000 (18:33 +0000)
committerVitaly Buka <vitalybuka@google.com>
Tue, 17 Oct 2017 18:33:15 +0000 (18:33 +0000)
This overflow does not affect algorithm, so just suppress it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316018 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 63bf68e..e7388f6 100644 (file)
@@ -5439,7 +5439,7 @@ static bool ReduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
   // 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