[llvm-commits] [llvm] r70134 - in /llvm/trunk: docs/LangRef.html lib/VMCore/Type.cpp test/Assembler/getelementptr_struct.ll

Sanjiv Gupta sanjiv.gupta at microchip.com
Sun Apr 26 10:14:35 PDT 2009


Author: sgupta
Date: Sun Apr 26 12:14:35 2009
New Revision: 70134

URL: http://llvm.org/viewvc/llvm-project?rev=70134&view=rev
Log:
Any size of integral indices are allowed in gep for indexing into sequential types. Also adding a test case to check the indices type allowed into struct.

Added:
    llvm/trunk/test/Assembler/getelementptr_struct.ll
Modified:
    llvm/trunk/docs/LangRef.html
    llvm/trunk/lib/VMCore/Type.cpp

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=70134&r1=70133&r2=70134&view=diff

==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Sun Apr 26 12:14:35 2009
@@ -3629,7 +3629,7 @@
 <p>The type of each index argument depends on the type it is indexing into.
 When indexing into a (packed) structure, only <tt>i32</tt> integer
 <b>constants</b> are allowed.  When indexing into an array, pointer or vector,
-only integers of 16, 32 or 64 bits are allowed (also non-constants). 16-bit
+integers of any width are allowed (also non-constants). 16-bit
 values will be sign extended to 32-bits if required, and 32-bit values
 will be sign extended to 64-bits if required.</p>
 

Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=70134&r1=70133&r2=70134&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Sun Apr 26 12:14:35 2009
@@ -1410,9 +1410,8 @@
 }
 
 bool SequentialType::indexValid(const Value *V) const {
-  if (const IntegerType *IT = dyn_cast<IntegerType>(V->getType())) 
-    return IT->getBitWidth() == 16 || IT->getBitWidth() == 32 ||
-           IT->getBitWidth() == 64;
+  if (isa<IntegerType>(V->getType())) 
+    return true;
   return false;
 }
 

Added: llvm/trunk/test/Assembler/getelementptr_struct.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/getelementptr_struct.ll?rev=70134&view=auto

==============================================================================
--- llvm/trunk/test/Assembler/getelementptr_struct.ll (added)
+++ llvm/trunk/test/Assembler/getelementptr_struct.ll Sun Apr 26 12:14:35 2009
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s >/dev/null |& grep {invalid getelementptr indices}
+; Test the case of a incorrect indices type into struct
+
+%RT = type { i8 , [10 x [20 x i32]], i8  }
+%ST = type { i32, double, %RT }
+
+define i32* @foo(%ST* %s) {
+entry:
+  %reg = getelementptr %ST* %s, i32 1, i64 2, i32 1, i32 5, i32 13
+  ret i32* %reg
+}
+





More information about the llvm-commits mailing list