[llvm-commits] [llvm] r79226 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2009-08-16-VLA.ll

Nick Lewycky nicholas at mxc.ca
Sun Aug 16 22:37:31 PDT 2009


Author: nicholas
Date: Mon Aug 17 00:37:31 2009
New Revision: 79226

URL: http://llvm.org/viewvc/llvm-project?rev=79226&view=rev
Log:
Don't crash trying to promote VLAs.

Added:
    llvm/trunk/test/Transforms/ScalarRepl/2009-08-16-VLA.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=79226&r1=79225&r2=79226&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Aug 17 00:37:31 2009
@@ -255,9 +255,12 @@
     // value cannot be decomposed at all.
     uint64_t AllocaSize = TD->getTypeAllocSize(AI->getAllocatedType());
 
+    // Do not promote [0 x %struct].
+    if (AllocaSize == 0) continue;
+
     // Do not promote any struct whose size is too big.
     if (AllocaSize > SRThreshold) continue;
-        
+
     if ((isa<StructType>(AI->getAllocatedType()) ||
          isa<ArrayType>(AI->getAllocatedType())) &&
         // Do not promote any struct into more than "32" separate vars.

Added: llvm/trunk/test/Transforms/ScalarRepl/2009-08-16-VLA.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2009-08-16-VLA.ll?rev=79226&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/ScalarRepl/2009-08-16-VLA.ll (added)
+++ llvm/trunk/test/Transforms/ScalarRepl/2009-08-16-VLA.ll Mon Aug 17 00:37:31 2009
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -scalarrepl -disable-opt
+
+	%struct.Item = type { [4 x i16], %struct.rule* }
+	%struct.rule = type { [4 x i16], i32, i32, i32, %struct.nonterminal*, %struct.pattern*, i8 }
+	%struct.nonterminal = type { i8*, i32, i32, i32, %struct.plankMap*, %struct.rule* }
+	%struct.plankMap = type { %struct.list*, i32, %struct.stateMap* }
+	%struct.list = type { i8*, %struct.list* }
+	%struct.stateMap = type { i8*, %struct.plank*, i32, i16* }
+	%struct.plank = type { i8*, %struct.list*, i32 }
+	%struct.pattern = type { %struct.nonterminal*, %struct.operator*, [2 x %struct.nonterminal*] }
+	%struct.operator = type { i8*, i8, i32, i32, i32, i32, %struct.table* }
+	%struct.table = type { %struct.operator*, %struct.list*, i16*, [2 x %struct.dimension*], %struct.item_set** }
+	%struct.dimension = type { i16*, %struct.Index_Map, %struct.mapping*, i32, %struct.plankMap* }
+	%struct.Index_Map = type { i32, %struct.item_set** }
+	%struct.item_set = type { i32, i32, %struct.operator*, [2 x %struct.item_set*], %struct.item_set*, i16*, %struct.Item*, %struct.Item* }
+	%struct.mapping = type { %struct.list**, i32, i32, i32, %struct.item_set** }
+
+define void @addHP_2_0() {
+bb4.i:
+	%0 = malloc [0 x %struct.Item]		; <[0 x %struct.Item]*> [#uses=1]
+	%.sub.i.c.i = getelementptr [0 x %struct.Item]* %0, i32 0, i32 0		; <%struct.Item*> [#uses=0]
+	unreachable
+}





More information about the llvm-commits mailing list