diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-05-12 07:21:09 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-05-12 07:21:09 +0000 |
commit | 8769403d4996ca745a3d6cef3c29a73c0ab961db (patch) | |
tree | ba4d4e432735694587cbf81349fd4cf550a4604d /llvm/lib/Support/APInt.cpp | |
parent | 6f586731c52302c988f3ac6245621b0da6e077c8 (diff) | |
download | bcm5719-llvm-8769403d4996ca745a3d6cef3c29a73c0ab961db.tar.gz bcm5719-llvm-8769403d4996ca745a3d6cef3c29a73c0ab961db.zip |
[APInt] Fix a case where udivrem might delete and create a new allocation instead of reusing the original.
llvm-svn: 302882
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index d43e1a817c9..361fc97c2ec 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -1686,8 +1686,11 @@ void APInt::udivrem(const APInt &LHS, const APInt &RHS, // There is only one word to consider so use the native versions. uint64_t lhsValue = LHS.U.pVal[0]; uint64_t rhsValue = RHS.U.pVal[0]; - Quotient = APInt(LHS.getBitWidth(), lhsValue / rhsValue); - Remainder = APInt(LHS.getBitWidth(), lhsValue % rhsValue); + // Make sure there is enough space to hold the results. + Quotient.reallocate(LHS.BitWidth); + Remainder.reallocate(LHS.BitWidth); + Quotient = lhsValue / rhsValue; + Remainder = lhsValue % rhsValue; return; } |