From d2142aeb447e8f9762f29875cccbe80a6de001ae Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 20 Feb 2008 22:36:03 +0000 Subject: [PATCH] What if functions can return aggregate values ? One small step towards multiple return value support. llvm-svn: 47406 --- lib/VMCore/Function.cpp | 3 ++- lib/VMCore/Type.cpp | 3 ++- lib/VMCore/Verifier.cpp | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index cbe11f0b6c5..ee386630d7d 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -179,7 +179,8 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage, ParamAttrs(0) { SymTab = new ValueSymbolTable(); - assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy) + assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy + || getReturnType()->getTypeID() == Type::StructTyID) && "LLVM functions cannot return aggregate values!"); // If the function has arguments, mark them as lazily built. diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 3000730be23..42c3770913d 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -443,7 +443,8 @@ FunctionType::FunctionType(const Type *Result, ContainedTys = reinterpret_cast(this+1); NumContainedTys = Params.size() + 1; // + 1 for result type assert((Result->isFirstClassType() || Result == Type::VoidTy || - isa(Result)) && + Result->getTypeID() == Type::StructTyID || + isa(Result)) && "LLVM functions cannot return aggregates"); bool isAbstract = Result->isAbstract(); new (&ContainedTys[0]) PATypeHandle(Result, this); diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 26bb2347b13..4bd2ba6c624 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -451,7 +451,8 @@ void Verifier::visitFunction(Function &F) { "# formal arguments must match # of arguments for function type!", &F, FT); Assert1(F.getReturnType()->isFirstClassType() || - F.getReturnType() == Type::VoidTy, + F.getReturnType() == Type::VoidTy || + F.getReturnType()->getTypeID() == Type::StructTyID, "Functions cannot return aggregate values!", &F); Assert1(!F.isStructReturn() || FT->getReturnType() == Type::VoidTy, @@ -1090,7 +1091,9 @@ void Verifier::visitInstruction(Instruction &I) { // Check to make sure that only first-class-values are operands to // instructions. - Assert1(I.getOperand(i)->getType()->isFirstClassType(), + Assert1(I.getOperand(i)->getType()->isFirstClassType() + || (isa(I) + && I.getOperand(i)->getType()->getTypeID() == Type::StructTyID), "Instruction operands must be first-class values!", &I); if (Function *F = dyn_cast(I.getOperand(i))) {