diff options
author | Nirav Dave <niravd@google.com> | 2019-02-26 15:02:32 +0000 |
---|---|---|
committer | Nirav Dave <niravd@google.com> | 2019-02-26 15:02:32 +0000 |
commit | 582d46328ce644d791f4dce31b005fc260d33611 (patch) | |
tree | 4c483fe2a5cdb8731a0234e1b78b20a296d72988 /llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp | |
parent | f388d17d7cad33afee059b0fe8d6c7b2b3e6899e (diff) | |
download | bcm5719-llvm-582d46328ce644d791f4dce31b005fc260d33611.tar.gz bcm5719-llvm-582d46328ce644d791f4dce31b005fc260d33611.zip |
[DAG] Fix constant store folding to handle non-byte sizes.
Avoid crashes from zero-byte values due to sub-byte store sizes.
Reviewers: uabelho, courbet, rnk
Reviewed By: courbet
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58626
llvm-svn: 354884
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp index b0dcf476db3..f5adfa542a3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp @@ -135,9 +135,10 @@ bool BaseIndexOffset::computeAliasing(const BaseIndexOffset &BasePtr0, return false; // Cannot determine whether the pointers alias. } -bool BaseIndexOffset::contains(int64_t Size, const BaseIndexOffset &Other, - int64_t OtherSize, const SelectionDAG &DAG, - int64_t &Offset) const { +bool BaseIndexOffset::contains(const SelectionDAG &DAG, int64_t BitSize, + const BaseIndexOffset &Other, + int64_t OtherBitSize, int64_t &BitOffset) const { + int64_t Offset; if (!equalBaseIndex(Other, DAG, Offset)) return false; if (Offset >= 0) { @@ -145,7 +146,8 @@ bool BaseIndexOffset::contains(int64_t Size, const BaseIndexOffset &Other, // [-------*this---------] // [---Other--] // ==Offset==> - return Offset + OtherSize <= Size; + BitOffset = 8 * Offset; + return BitOffset + OtherBitSize <= BitSize; } // Other starts strictly before *this, it cannot be fully contained. // [-------*this---------] |