summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/DerivedTypes.h5
-rw-r--r--llvm/include/llvm/IR/Type.h2
-rw-r--r--llvm/test/Assembler/invalid-inttype.ll5
-rw-r--r--llvm/test/Assembler/max-inttype.ll4
4 files changed, 14 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index efd0d07366e..a59049b22e8 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -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.
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index 9cf03d86e0d..52ef5605f7d 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -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/llvm/test/Assembler/invalid-inttype.ll b/llvm/test/Assembler/invalid-inttype.ll
new file mode 100644
index 00000000000..145153d8f11
--- /dev/null
+++ b/llvm/test/Assembler/invalid-inttype.ll
@@ -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/llvm/test/Assembler/max-inttype.ll b/llvm/test/Assembler/max-inttype.ll
new file mode 100644
index 00000000000..10eed60f3db
--- /dev/null
+++ b/llvm/test/Assembler/max-inttype.ll
@@ -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
OpenPOWER on IntegriCloud