summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-07-13 02:49:08 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-07-13 02:49:08 +0000
commit73b704dd9c694d3c4641befa20fa00a7fee06065 (patch)
tree27754ece444dc09bad263c54c74dccf0d661eee0 /llvm
parente7cabb94a3406eb1e7b6a55e89cada922bdee725 (diff)
downloadbcm5719-llvm-73b704dd9c694d3c4641befa20fa00a7fee06065.tar.gz
bcm5719-llvm-73b704dd9c694d3c4641befa20fa00a7fee06065.zip
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! llvm-svn: 75443
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Support/ConstantRange.cpp2
-rw-r--r--llvm/unittests/Support/ConstantRangeTest.cpp1
2 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp
index 04a1b68e072..8bab5377952 100644
--- a/llvm/lib/Support/ConstantRange.cpp
+++ b/llvm/lib/Support/ConstantRange.cpp
@@ -533,6 +533,8 @@ ConstantRange
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();
diff --git a/llvm/unittests/Support/ConstantRangeTest.cpp b/llvm/unittests/Support/ConstantRangeTest.cpp
index 891c209f11c..cd91a9e103c 100644
--- a/llvm/unittests/Support/ConstantRangeTest.cpp
+++ b/llvm/unittests/Support/ConstantRangeTest.cpp
@@ -239,6 +239,7 @@ TEST_F(ConstantRangeTest, SubtractAPInt) {
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);
OpenPOWER on IntegriCloud