diff options
author | Devang Patel <dpatel@apple.com> | 2008-02-21 01:54:02 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-02-21 01:54:02 +0000 |
commit | ffcdab923c500951f71b3dc428a0119815dfaf0f (patch) | |
tree | 12bc619006390b92f39e19ae5f77eb52f9deb8f0 /lib | |
parent | 42e66517d8c1a4e91ac25f1f9812525612822f39 (diff) | |
download | external_llvm-ffcdab923c500951f71b3dc428a0119815dfaf0f.zip external_llvm-ffcdab923c500951f71b3dc428a0119815dfaf0f.tar.gz external_llvm-ffcdab923c500951f71b3dc428a0119815dfaf0f.tar.bz2 |
Let function call return aggregate.
Now, we have very first multiple return value testcase!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Value.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 26 |
2 files changed, 26 insertions, 7 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 7b9d7f0..440e0a6 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -14,6 +14,7 @@ #include "llvm/Constant.h" #include "llvm/DerivedTypes.h" #include "llvm/InstrTypes.h" +#include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Support/Debug.h" @@ -33,7 +34,11 @@ static inline const Type *checkType(const Type *Ty) { Value::Value(const Type *ty, unsigned scid) : SubclassID(scid), SubclassData(0), Ty(checkType(ty)), UseList(0), Name(0) { - if (!isa<Constant>(this) && !isa<BasicBlock>(this)) + if (isa<CallInst>(this)) + assert((Ty->isFirstClassType() || Ty == Type::VoidTy || + isa<OpaqueType>(ty) || Ty->getTypeID() == Type::StructTyID) && + "invalid CallInst type!"); + else if (!isa<Constant>(this) && !isa<BasicBlock>(this)) assert((Ty->isFirstClassType() || Ty == Type::VoidTy || isa<OpaqueType>(ty)) && "Cannot create non-first-class values except for constants!"); diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 4bd2ba6..27adc08 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1071,7 +1071,8 @@ void Verifier::visitInstruction(Instruction &I) { // Check that the return value of the instruction is either void or a legal // value type. - Assert1(I.getType() == Type::VoidTy || I.getType()->isFirstClassType(), + Assert1(I.getType() == Type::VoidTy || I.getType()->isFirstClassType() + || (isa<CallInst>(I) && I.getType()->getTypeID() == Type::StructTyID), "Instruction returns a non-scalar type!", &I); // Check that all uses of the instruction, if they are instructions @@ -1091,11 +1092,24 @@ void Verifier::visitInstruction(Instruction &I) { // Check to make sure that only first-class-values are operands to // instructions. - Assert1(I.getOperand(i)->getType()->isFirstClassType() - || (isa<ReturnInst>(I) - && I.getOperand(i)->getType()->getTypeID() == Type::StructTyID), - "Instruction operands must be first-class values!", &I); - + if (!I.getOperand(i)->getType()->isFirstClassType()) { + if (isa<ReturnInst>(I) || isa<GetResultInst>(I)) + Assert1(I.getOperand(i)->getType()->getTypeID() == Type::StructTyID, + "Invalid ReturnInst operands!", &I); + else if (isa<CallInst>(I)) { + if (const PointerType *PT = dyn_cast<PointerType> + (I.getOperand(i)->getType())) { + const Type *ETy = PT->getElementType(); + Assert1(ETy->getTypeID() == Type::StructTyID, + "Invalid CallInst operands!", &I); + } + else + Assert1(0, "Invalid CallInst operands!", &I); + } + else + Assert1(0, "Instruction operands must be first-class values!", &I); + } + if (Function *F = dyn_cast<Function>(I.getOperand(i))) { // Check to make sure that the "address of" an intrinsic function is never // taken. |