[llvm-commits] [llvm] r108517 - in /llvm/trunk: lib/Transforms/IPO/MergeFunctions.cpp test/Transforms/MergeFunc/vectors-and-arrays.ll
Nick Lewycky
nicholas at mxc.ca
Thu Jul 15 23:31:13 PDT 2010
Author: nicholas
Date: Fri Jul 16 01:31:12 2010
New Revision: 108517
URL: http://llvm.org/viewvc/llvm-project?rev=108517&view=rev
Log:
Arrays and vectors with different numbers of elements are not equivalent.
Added:
llvm/trunk/test/Transforms/MergeFunc/vectors-and-arrays.ll
Modified:
llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=108517&r1=108516&r2=108517&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Fri Jul 16 01:31:12 2010
@@ -216,11 +216,17 @@
return true;
}
- case Type::ArrayTyID:
+ case Type::ArrayTyID: {
+ const ArrayType *ATy1 = cast<ArrayType>(Ty1);
+ const ArrayType *ATy2 = cast<ArrayType>(Ty2);
+ return ATy1->getNumElements() == ATy2->getNumElements() &&
+ isEquivalentType(ATy1->getElementType(), ATy2->getElementType());
+ }
case Type::VectorTyID: {
- const SequentialType *STy1 = cast<SequentialType>(Ty1);
- const SequentialType *STy2 = cast<SequentialType>(Ty2);
- return isEquivalentType(STy1->getElementType(), STy2->getElementType());
+ const VectorType *VTy1 = cast<VectorType>(Ty1);
+ const VectorType *VTy2 = cast<VectorType>(Ty2);
+ return VTy1->getNumElements() == VTy2->getNumElements() &&
+ isEquivalentType(VTy1->getElementType(), VTy2->getElementType());
}
}
}
Added: llvm/trunk/test/Transforms/MergeFunc/vectors-and-arrays.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MergeFunc/vectors-and-arrays.ll?rev=108517&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/MergeFunc/vectors-and-arrays.ll (added)
+++ llvm/trunk/test/Transforms/MergeFunc/vectors-and-arrays.ll Fri Jul 16 01:31:12 2010
@@ -0,0 +1,18 @@
+; RUN: opt -mergefunc < %s -disable-output -stats | not grep merged
+; This used to crash with an assert.
+
+define <2 x i8> @v1(<2 x i8> %x) {
+ ret <2 x i8> %x
+}
+
+define <4 x i8> @v2(<4 x i8> %x) {
+ ret <4 x i8> %x
+}
+
+define [2 x i8] @a1([2 x i8] %x) {
+ ret [2 x i8] %x
+}
+
+define [4 x i8] @a2([4 x i8] %x) {
+ ret [4 x i8] %x
+}
More information about the llvm-commits
mailing list