mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Fix really obscure bug in CannotBeNegativeZero() (PR22688)
With a diabolically crafted test case, we could recurse through this code and return true instead of false. The larger engineering crime is the use of magic numbers. Added FIXME comments for those. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230515 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -2000,8 +2000,11 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
|
||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V))
|
||||
return !CFP->getValueAPF().isNegZero();
|
||||
|
||||
// FIXME: Magic number! At the least, this should be given a name because it's
|
||||
// used similarly in CannotBeOrderedLessThanZero(). A better fix may be to
|
||||
// expose it as a parameter, so it can be used for testing / experimenting.
|
||||
if (Depth == 6)
|
||||
return 1; // Limit search depth.
|
||||
return false; // Limit search depth.
|
||||
|
||||
const Operator *I = dyn_cast<Operator>(V);
|
||||
if (!I) return false;
|
||||
@ -2048,6 +2051,9 @@ bool llvm::CannotBeOrderedLessThanZero(const Value *V, unsigned Depth) {
|
||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V))
|
||||
return !CFP->getValueAPF().isNegative() || CFP->getValueAPF().isZero();
|
||||
|
||||
// FIXME: Magic number! At the least, this should be given a name because it's
|
||||
// used similarly in CannotBeNegativeZero(). A better fix may be to
|
||||
// expose it as a parameter, so it can be used for testing / experimenting.
|
||||
if (Depth == 6)
|
||||
return false; // Limit search depth.
|
||||
|
||||
|
Reference in New Issue
Block a user