[llvm-commits] [llvm] r75443 - in /llvm/trunk: lib/Support/ConstantRange.cpp unittests/Support/ConstantRangeTest.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Jul 12 19:49:09 PDT 2009
Author: nicholas
Date: Sun Jul 12 21:49:08 2009
New Revision: 75443
URL: http://llvm.org/viewvc/llvm-project?rev=75443&view=rev
Log:
Fix a bug summing two full sets. The overflow checking doesn't handle sets as
large as the full set, only those one size smaller. Thanks to Daniel Dunbar
who found this bug using Klee!
Modified:
llvm/trunk/lib/Support/ConstantRange.cpp
llvm/trunk/unittests/Support/ConstantRangeTest.cpp
Modified: llvm/trunk/lib/Support/ConstantRange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=75443&r1=75442&r2=75443&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ConstantRange.cpp (original)
+++ llvm/trunk/lib/Support/ConstantRange.cpp Sun Jul 12 21:49:08 2009
@@ -533,6 +533,8 @@
ConstantRange::add(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
+ if (isFullSet() || Other.isFullSet())
+ return ConstantRange(getBitWidth(), /*isFullSet=*/true);
APInt Spread_X = getSetSize(), Spread_Y = Other.getSetSize();
APInt NewLower = getLower() + Other.getLower();
Modified: llvm/trunk/unittests/Support/ConstantRangeTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ConstantRangeTest.cpp?rev=75443&r1=75442&r2=75443&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ConstantRangeTest.cpp (original)
+++ llvm/trunk/unittests/Support/ConstantRangeTest.cpp Sun Jul 12 21:49:08 2009
@@ -239,6 +239,7 @@
TEST_F(ConstantRangeTest, Add) {
EXPECT_TRUE(Full.add(APInt(16, 4)).isFullSet());
+ EXPECT_EQ(Full.add(Full), Full);
EXPECT_EQ(Full.add(Empty), Empty);
EXPECT_EQ(Full.add(One), Full);
EXPECT_EQ(Full.add(Some), Full);
More information about the llvm-commits
mailing list