[llvm] r283215 - Fix IntegerType::MAX_INT_BITS value
Andrey Bokhanko via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 05:43:47 PDT 2016
Author: asbokhan
Date: Tue Oct 4 07:43:46 2016
New Revision: 283215
URL: http://llvm.org/viewvc/llvm-project?rev=283215&view=rev
Log:
Fix IntegerType::MAX_INT_BITS value
IntegerType::MAX_INT_BITS is apparently not in sync with Type::SubclassData
size. This patch fixes this.
Differential Revision: https://reviews.llvm.org/D24814
Added:
llvm/trunk/test/Assembler/invalid-inttype.ll
llvm/trunk/test/Assembler/max-inttype.ll
Modified:
llvm/trunk/include/llvm/IR/DerivedTypes.h
llvm/trunk/include/llvm/IR/Type.h
Modified: llvm/trunk/include/llvm/IR/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DerivedTypes.h?rev=283215&r1=283214&r2=283215&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/IR/DerivedTypes.h Tue Oct 4 07:43:46 2016
@@ -46,9 +46,10 @@ public:
/// This enum is just used to hold constants we need for IntegerType.
enum {
MIN_INT_BITS = 1, ///< Minimum number of bits that can be specified
- MAX_INT_BITS = (1<<23)-1 ///< Maximum number of bits that can be specified
+ MAX_INT_BITS = (1<<24)-1 ///< Maximum number of bits that can be specified
///< Note that bit width is stored in the Type classes SubclassData field
- ///< which has 23 bits. This yields a maximum bit width of 8,388,607 bits.
+ ///< which has 24 bits. This yields a maximum bit width of 16,777,215
+ ///< bits.
};
/// This static method is the primary way of constructing an IntegerType.
Modified: llvm/trunk/include/llvm/IR/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Type.h?rev=283215&r1=283214&r2=283215&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Type.h (original)
+++ llvm/trunk/include/llvm/IR/Type.h Tue Oct 4 07:43:46 2016
@@ -81,6 +81,8 @@ private:
TypeID ID : 8; // The current base type of this type.
unsigned SubclassData : 24; // Space for subclasses to store data.
+ // Note that this should be synchronized with
+ // MAX_INT_BITS value in IntegerType class.
protected:
friend class LLVMContextImpl;
Added: llvm/trunk/test/Assembler/invalid-inttype.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-inttype.ll?rev=283215&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-inttype.ll (added)
+++ llvm/trunk/test/Assembler/invalid-inttype.ll Tue Oct 4 07:43:46 2016
@@ -0,0 +1,5 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; i16777216 is the smallest integer type that can't be represented in LLVM IR
+ at i2 = common global i16777216 0, align 4
+; CHECK: expected type
Added: llvm/trunk/test/Assembler/max-inttype.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/max-inttype.ll?rev=283215&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/max-inttype.ll (added)
+++ llvm/trunk/test/Assembler/max-inttype.ll Tue Oct 4 07:43:46 2016
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s | llvm-dis
+
+; i16777215 is the maximum integer type represented in LLVM IR
+ at i2 = common global i16777215 0, align 4
More information about the llvm-commits
mailing list