aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-06-09 21:26:13 +0000
committerDan Gohman <gohman@apple.com>2008-06-09 21:26:13 +0000
commit7dc1def1623748b6c2f1812f1bf2e0153759c8b9 (patch)
treeff89de95aa85e554d4c3b235002b15369dd3844d /lib/VMCore/Verifier.cpp
parentf5025cfa683b4cfb9f04b1e63dac7364a5dbf900 (diff)
downloadexternal_llvm-7dc1def1623748b6c2f1812f1bf2e0153759c8b9.zip
external_llvm-7dc1def1623748b6c2f1812f1bf2e0153759c8b9.tar.gz
external_llvm-7dc1def1623748b6c2f1812f1bf2e0153759c8b9.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index ac529e3..0ce7d4c 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -594,7 +594,10 @@ void Verifier::visitReturnInst(ReturnInst &RI) {
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 @@ void Verifier::visitReturnInst(ReturnInst &RI) {
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