diff options
author | Gerolf Hoflehner <ghoflehner@apple.com> | 2018-02-12 21:49:32 +0000 |
---|---|---|
committer | Gerolf Hoflehner <ghoflehner@apple.com> | 2018-02-12 21:49:32 +0000 |
commit | edcd56482066d78edac2d1471712f6bfac481646 (patch) | |
tree | 218c0031470289aafe5c6663e33c1fa62b4a6992 /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | ca358da5e796ef8ae19e4651b758a61ea72d2bfe (diff) | |
download | bcm5719-llvm-edcd56482066d78edac2d1471712f6bfac481646.tar.gz bcm5719-llvm-edcd56482066d78edac2d1471712f6bfac481646.zip |
[LSR] Avoid UB overflow when examining reuse opportunities
llvm-svn: 324943
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index b7d9a258913..8b6e5e34b40 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -3939,6 +3939,11 @@ void LSRInstance::GenerateCrossUseConstantOffsets() { if (Imms.size() == 1) continue; + // UB: Check for overflow + int64_t Res; + if (__builtin_saddll_overflow(Imms.begin()->first, std::prev(Imms.end())->first, &Res)) + continue; + DEBUG(dbgs() << "Generating cross-use offsets for " << *Reg << ':'; for (const auto &Entry : Imms) dbgs() << ' ' << Entry.first; |