[llvm-commits] [llvm] r52157 - in /llvm/trunk: lib/VMCore/Verifier.cpp test/Assembler/aggregate-constant-values.ll test/Assembler/aggregate-return-single-value.ll
Dan Gohman
gohman at apple.com
Mon Jun 9 14:26:13 PDT 2008
Author: djg
Date: Mon Jun 9 16:26:13 2008
New Revision: 52157
URL: http://llvm.org/viewvc/llvm-project?rev=52157&view=rev
Log:
Re-apply 52002, allowing the verifier to accept non-MRV struct return
types on functions, with adjustments so that it accepts both
new-style aggregate returns and old-style MRV returns, including those
with only a single member.
Added:
llvm/trunk/test/Assembler/aggregate-constant-values.ll
llvm/trunk/test/Assembler/aggregate-return-single-value.ll
Modified:
llvm/trunk/lib/VMCore/Verifier.cpp
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=52157&r1=52156&r2=52157&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Jun 9 16:26:13 2008
@@ -594,7 +594,10 @@
Assert2(N == 0,
"Found return instr that returns void in Function of non-void "
"return type!", &RI, F->getReturnType());
- else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
+ else if (N == 1 && F->getReturnType() == RI.getOperand(0)->getType()) {
+ // Exactly one return value and it matches the return type. Good.
+ } else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
+ // The return type is a struct; check for multiple return values.
Assert2(STy->getNumElements() == N,
"Incorrect number of return values in ret instruction!",
&RI, F->getReturnType());
@@ -602,10 +605,18 @@
Assert2(STy->getElementType(i) == RI.getOperand(i)->getType(),
"Function return type does not match operand "
"type of return inst!", &RI, F->getReturnType());
+ } else if (const ArrayType *ATy = dyn_cast<ArrayType>(F->getReturnType())) {
+ // The return type is an array; check for multiple return values.
+ Assert2(ATy->getNumElements() == N,
+ "Incorrect number of return values in ret instruction!",
+ &RI, F->getReturnType());
+ for (unsigned i = 0; i != N; ++i)
+ Assert2(ATy->getElementType() == RI.getOperand(i)->getType(),
+ "Function return type does not match operand "
+ "type of return inst!", &RI, F->getReturnType());
} else {
- Assert2(N == 1 && F->getReturnType() == RI.getOperand(0)->getType(),
- "Function return type does not match operand "
- "type of return inst!", &RI, F->getReturnType());
+ CheckFailed("Function return type does not match operand "
+ "type of return inst!", &RI, F->getReturnType());
}
// Check to make sure that the return value has necessary properties for
Added: llvm/trunk/test/Assembler/aggregate-constant-values.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/aggregate-constant-values.ll?rev=52157&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/aggregate-constant-values.ll (added)
+++ llvm/trunk/test/Assembler/aggregate-constant-values.ll Mon Jun 9 16:26:13 2008
@@ -0,0 +1,27 @@
+; RUN: llvm-as < %s | llvm-dis | grep 7 | count 3
+
+define void @foo({i32, i32}* %x) nounwind {
+ store {i32, i32}{i32 7, i32 9}, {i32, i32}* %x
+ ret void
+}
+define void @foo_empty({}* %x) nounwind {
+ store {}{}, {}* %x
+ ret void
+}
+define void @bar([2 x i32]* %x) nounwind {
+ store [2 x i32][i32 7, i32 9], [2 x i32]* %x
+ ret void
+}
+define void @bar_empty([0 x i32]* %x) nounwind {
+ store [0 x i32][], [0 x i32]* %x
+ ret void
+}
+define void @qux(<{i32, i32}>* %x) nounwind {
+ store <{i32, i32}><{i32 7, i32 9}>, <{i32, i32}>* %x
+ ret void
+}
+define void @qux_empty(<{}>* %x) nounwind {
+ store <{}><{}>, <{}>* %x
+ ret void
+}
+
Added: llvm/trunk/test/Assembler/aggregate-return-single-value.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/aggregate-return-single-value.ll?rev=52157&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/aggregate-return-single-value.ll (added)
+++ llvm/trunk/test/Assembler/aggregate-return-single-value.ll Mon Jun 9 16:26:13 2008
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | llvm-dis
+
+define { i32 } @fooa() nounwind {
+ ret i32 0
+}
+define { i32 } @foob() nounwind {
+ ret {i32}{ i32 0 }
+}
+define [1 x i32] @fooc() nounwind {
+ ret i32 0
+}
+define [1 x i32] @food() nounwind {
+ ret [1 x i32][ i32 0 ]
+}
More information about the llvm-commits
mailing list