diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-25 02:31:26 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-25 02:31:26 +0000 |
commit | e1433f24cf714c49b266e8cefdbbb8a464ffcb8e (patch) | |
tree | 356042634b817c6a9c316a63f5c0af2f6e7a2b1f /lib/VMCore | |
parent | 27acd3a999ec3790e6af1d6416295caab5033320 (diff) | |
download | external_llvm-e1433f24cf714c49b266e8cefdbbb8a464ffcb8e.zip external_llvm-e1433f24cf714c49b266e8cefdbbb8a464ffcb8e.tar.gz external_llvm-e1433f24cf714c49b266e8cefdbbb8a464ffcb8e.tar.bz2 |
Noting and enforcing that GC intrinsics are valid only within a
function with GC.
This will catch the error when the inliner inlines a function with
GC into a caller with no GC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index e6495a0..df0cb99 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1167,37 +1167,45 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { switch (ID) { default: 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::gcroot: + case Intrinsic::gcwrite: 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); + + switch (ID) { + default: + break; + case Intrinsic::gcroot: + 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: + 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: + 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; + } + + Assert1(CI.getParent()->getParent()->hasCollector(), + "Enclosing function does not specify a collector algorithm.", + &CI); } break; case Intrinsic::init_trampoline: Assert1(isa<Function>(IntrinsicInst::StripPointerCasts(CI.getOperand(2))), |