mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[APInt] Fix a case where udivrem might delete and create a new allocation instead of reusing the original.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302882 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user