[llvm-commits] [llvm] r101662 - in /llvm/trunk: lib/Target/TargetData.cpp test/CodeGen/Generic/crash.ll

Chris Lattner sabre at nondot.org
Sat Apr 17 12:02:33 PDT 2010


Author: lattner
Date: Sat Apr 17 14:02:33 2010
New Revision: 101662

URL: http://llvm.org/viewvc/llvm-project?rev=101662&view=rev
Log:
fix PR6332, allowing an index of zero into a zero sized array 
even if the element of the array has no size.

Added:
    llvm/trunk/test/CodeGen/Generic/crash.ll
Modified:
    llvm/trunk/lib/Target/TargetData.cpp

Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=101662&r1=101661&r2=101662&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Sat Apr 17 14:02:33 2010
@@ -630,8 +630,8 @@
       Ty = cast<SequentialType>(Ty)->getElementType();
 
       // Get the array index and the size of each array element.
-      int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue();
-      Result += arrayIdx * (int64_t)getTypeAllocSize(Ty);
+      if (int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue())
+        Result += arrayIdx * (int64_t)getTypeAllocSize(Ty);
     }
   }
 

Added: llvm/trunk/test/CodeGen/Generic/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/crash.ll?rev=101662&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/crash.ll (added)
+++ llvm/trunk/test/CodeGen/Generic/crash.ll Sat Apr 17 14:02:33 2010
@@ -0,0 +1,8 @@
+; RUN: llc %s -o -
+
+; PR6332
+%struct.AVCodecTag = type opaque
+ at ff_codec_bmp_tags = external global [0 x %struct.AVCodecTag]
+ at tags = global [1 x %struct.AVCodecTag*] [%struct.AVCodecTag* getelementptr
+inbounds ([0 x %struct.AVCodecTag]* @ff_codec_bmp_tags, i32 0, i32 0)]
+





More information about the llvm-commits mailing list