diff options
author | Dan Gohman <gohman@apple.com> | 2009-01-27 20:39:34 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-01-27 20:39:34 +0000 |
commit | ce9bc12c6f3c3544f7518c0c60203f2f9dff342f (patch) | |
tree | a60dd3cbe68329a1fa1e55da165597ddfeecc67c /include/llvm/CodeGen | |
parent | d3f184906d341924fbebe9b09e225c624b4e0474 (diff) |
Add an assertion to the form of SelectionDAG::getConstant that takes
a uint64_t to verify that the value is in range for the given type,
to help catch accidental overflow. Fix a few places that relied on
getConstant implicitly truncating the value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/ValueTypes.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 1a08f4d608..2846eb02db 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -444,8 +444,11 @@ namespace llvm { /// getIntegerVTBitMask - Return an integer with 1's every place there are /// bits in the specified integer value type. FIXME: Should return an apint. uint64_t getIntegerVTBitMask() const { - assert(isInteger() && !isVector() && "Only applies to int scalars!"); - return ~uint64_t(0UL) >> (64-getSizeInBits()); + assert(isInteger() && "Only applies to integers!"); + MVT EltVT = isVector() ? getVectorElementType() : *this; + assert(EltVT.getSizeInBits() <= 64 && + "getIntegerVTBitMask doesn't use APInt!"); + return ~uint64_t(0UL) >> (64-EltVT.getSizeInBits()); } /// getIntegerVTSignBit - Return an integer with a 1 in the position of the |