diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-23 00:34:11 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-23 00:34:11 +0000 |
commit | fc74abfba5128544a750fce22fdf13eb0403e3ce (patch) | |
tree | 36ed972103bbbb170370e4e6688787ed5f1f9ac8 /lib/VMCore/Verifier.cpp | |
parent | 5e6ebaf4d1d3043d3428b65ee8054c71c24af930 (diff) | |
download | external_llvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.zip external_llvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.tar.gz external_llvm-fc74abfba5128544a750fce22fdf13eb0403e3ce.tar.bz2 |
Enable first-class aggregates support.
Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.
The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 79c24f3..0aef414 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -259,7 +259,8 @@ namespace { void visitUserOp2(Instruction &I) { visitUserOp1(I); } void visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI); void visitAllocationInst(AllocationInst &AI); - void visitGetResultInst(GetResultInst &GRI); + void visitExtractValueInst(ExtractValueInst &EVI); + void visitInsertValueInst(InsertValueInst &IVI); void VerifyCallSite(CallSite CS); void VerifyIntrinsicPrototype(Intrinsic::ID ID, Function *F, @@ -1090,18 +1091,23 @@ void Verifier::visitAllocationInst(AllocationInst &AI) { visitInstruction(AI); } -void Verifier::visitGetResultInst(GetResultInst &GRI) { - Assert1(GetResultInst::isValidOperands(GRI.getAggregateValue(), - GRI.getIndex()), - "Invalid GetResultInst operands!", &GRI); - Assert1(isa<CallInst>(GRI.getAggregateValue()) || - isa<InvokeInst>(GRI.getAggregateValue()) || - isa<UndefValue>(GRI.getAggregateValue()), - "GetResultInst operand must be a call/invoke/undef!", &GRI); +void Verifier::visitExtractValueInst(ExtractValueInst &EVI) { + Assert1(ExtractValueInst::getIndexedType(EVI.getAggregateOperand()->getType(), + EVI.idx_begin(), EVI.idx_end()) == + EVI.getType(), + "Invalid ExtractValueInst operands!", &EVI); - visitInstruction(GRI); + visitInstruction(EVI); } +void Verifier::visitInsertValueInst(InsertValueInst &IVI) { + Assert1(ExtractValueInst::getIndexedType(IVI.getAggregateOperand()->getType(), + IVI.idx_begin(), IVI.idx_end()) == + IVI.getOperand(1)->getType(), + "Invalid InsertValueInst operands!", &IVI); + + visitInstruction(IVI); +} /// verifyInstruction - Verify that an instruction is well formed. /// @@ -1151,20 +1157,7 @@ void Verifier::visitInstruction(Instruction &I) { // Check to make sure that only first-class-values are operands to // instructions. if (!I.getOperand(i)->getType()->isFirstClassType()) { - if (isa<ReturnInst>(I) || isa<GetResultInst>(I)) - Assert1(isa<StructType>(I.getOperand(i)->getType()), - "Invalid ReturnInst operands!", &I); - else if (isa<CallInst>(I) || isa<InvokeInst>(I)) { - if (const PointerType *PT = dyn_cast<PointerType> - (I.getOperand(i)->getType())) { - const Type *ETy = PT->getElementType(); - Assert1(isa<StructType>(ETy), "Invalid CallInst operands!", &I); - } - else - Assert1(0, "Invalid CallInst operands!", &I); - } - else - Assert1(0, "Instruction operands must be first-class values!", &I); + Assert1(0, "Instruction operands must be first-class values!", &I); } if (Function *F = dyn_cast<Function>(I.getOperand(i))) { |