diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-25 02:02:10 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-25 02:02:10 +0000 |
commit | 247902aa9c071c5d62e83f4177ad74a742f3fe48 (patch) | |
tree | 7dcbdb29bed3b3e2e17b92378e3e8704115190fe /lib/VMCore | |
parent | 7e1df66f1d7dd983c59d5e6dc23b6dd52a2629b2 (diff) | |
download | external_llvm-247902aa9c071c5d62e83f4177ad74a742f3fe48.zip external_llvm-247902aa9c071c5d62e83f4177ad74a742f3fe48.tar.gz external_llvm-247902aa9c071c5d62e83f4177ad74a742f3fe48.tar.bz2 |
Adjusting verification of "llvm.gc*" intrinsic prototypes to match
LangRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 901a4c5..e6495a0 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1153,12 +1153,6 @@ void Verifier::visitInstruction(Instruction &I) { InstsInThisBlock.insert(&I); } -static bool HasPtrPtrType(Value *Val) { - if (const PointerType *PtrTy = dyn_cast<PointerType>(Val->getType())) - return isa<PointerType>(PtrTy->getElementType()); - return false; -} - /// visitIntrinsicFunction - Allow intrinsics to be verified in different ways. /// void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { @@ -1173,30 +1167,43 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { switch (ID) { default: break; - case Intrinsic::gcroot: - Assert1(HasPtrPtrType(CI.getOperand(1)), - "llvm.gcroot parameter #1 must be a pointer to a pointer.", &CI); - Assert1(isa<AllocaInst>(IntrinsicInst::StripPointerCasts(CI.getOperand(1))), - "llvm.gcroot parameter #1 must be an alloca (or a bitcast of one).", - &CI); - Assert1(isa<Constant>(CI.getOperand(2)), - "llvm.gcroot parameter #2 must be a constant.", &CI); - break; - case Intrinsic::gcwrite: - Assert1(CI.getOperand(3)->getType() - == PointerType::getUnqual(CI.getOperand(1)->getType()), - "Call to llvm.gcwrite must be with type 'void (%ty*, %ty2*, %ty**)'.", - &CI); - break; - case Intrinsic::gcread: - Assert1(CI.getOperand(2)->getType() == PointerType::getUnqual(CI.getType()), - "Call to llvm.gcread must be with type '%ty* (%ty2*, %ty**).'", - &CI); - break; + case Intrinsic::gcroot: { + Type *PtrTy = PointerType::getUnqual(Type::Int8Ty), + *PtrPtrTy = PointerType::getUnqual(PtrTy); + Assert1(CI.getOperand(1)->getType() == PtrPtrTy, + "Intrinsic parameter #1 is not i8**.", &CI); + Assert1(CI.getOperand(2)->getType() == PtrTy, + "Intrinsic parameter #2 is not i8*.", &CI); + Assert1( + isa<AllocaInst>(IntrinsicInst::StripPointerCasts(CI.getOperand(1))), + "llvm.gcroot parameter #1 must be an alloca.", + &CI); + Assert1(isa<Constant>(CI.getOperand(2)), + "llvm.gcroot parameter #2 must be a constant.", &CI); + } break; + case Intrinsic::gcwrite: { + Type *PtrTy = PointerType::getUnqual(Type::Int8Ty), + *PtrPtrTy = PointerType::getUnqual(PtrTy); + Assert1(CI.getOperand(1)->getType() == PtrTy, + "Intrinsic parameter #1 is not a i8*.", &CI); + Assert1(CI.getOperand(2)->getType() == PtrTy, + "Intrinsic parameter #2 is not a i8*.", &CI); + Assert1(CI.getOperand(3)->getType() == PtrPtrTy, + "Intrinsic parameter #3 is not a i8**.", &CI); + } break; + case Intrinsic::gcread: { + Type *PtrTy = PointerType::getUnqual(Type::Int8Ty), + *PtrPtrTy = PointerType::getUnqual(PtrTy); + Assert1(CI.getOperand(1)->getType() == PtrTy, + "Intrinsic parameter #1 is not a i8*.", &CI); + Assert1(CI.getOperand(2)->getType() == PtrPtrTy, + "Intrinsic parameter #2 is not a i8**.", &CI); + } break; case Intrinsic::init_trampoline: Assert1(isa<Function>(IntrinsicInst::StripPointerCasts(CI.getOperand(2))), "llvm.init_trampoline parameter #2 must resolve to a function.", &CI); + break; } } |