]> granicus.if.org Git - llvm/commitdiff
Fix IntegerType::MAX_INT_BITS value
authorAndrey Bokhanko <andreybokhanko@gmail.com>
Tue, 4 Oct 2016 12:43:46 +0000 (12:43 +0000)
committerAndrey Bokhanko <andreybokhanko@gmail.com>
Tue, 4 Oct 2016 12:43:46 +0000 (12:43 +0000)
IntegerType::MAX_INT_BITS is apparently not in sync with Type::SubclassData
size. This patch fixes this.

Differential Revision: https://reviews.llvm.org/D24814

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283215 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DerivedTypes.h
include/llvm/IR/Type.h
test/Assembler/invalid-inttype.ll [new file with mode: 0644]
test/Assembler/max-inttype.ll [new file with mode: 0644]

index efd0d07366ee01b4133cf5d2c6669e8b5f282884..a59049b22e849ddac934c9e76c6e79913c66334a 100644 (file)
@@ -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.
index 9cf03d86e0d1465f8a196f6c7f99dbfcd1808ab4..52ef5605f7d139e150df2bbcd78edec7c561f21a 100644 (file)
@@ -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;
diff --git a/test/Assembler/invalid-inttype.ll b/test/Assembler/invalid-inttype.ll
new file mode 100644 (file)
index 0000000..145153d
--- /dev/null
@@ -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
+@i2 = common global i16777216 0, align 4
+; CHECK: expected type
diff --git a/test/Assembler/max-inttype.ll b/test/Assembler/max-inttype.ll
new file mode 100644 (file)
index 0000000..10eed60
--- /dev/null
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s | llvm-dis
+
+; i16777215 is the maximum integer type represented in LLVM IR
+@i2 = common global i16777215 0, align 4