From 6d8635a74343d3ed7d19cb63edd4e508e9218fb4 Mon Sep 17 00:00:00 2001 From: Chen Li Date: Mon, 18 May 2015 19:50:14 +0000 Subject: [Verifier] Assert gc_relocate always return a pointer type Summary: Add an assertion in verifier.cpp to make sure gc_relocate relocate a gc pointer, and its return type has the same address space with the relocated pointer. Reviewers: reames, AndyAyers, sanjoy, pgavlin Reviewed By: pgavlin Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9695 llvm-svn: 237605 --- llvm/lib/IR/Verifier.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index f4bc289cf26..5dae4e08ced 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3440,8 +3440,18 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { "'gc parameters' section of the statepoint call", &CI); - // gc_relocate does not need to be the same type as the relocated pointer. - // It can casted to the correct type later if it's desired + // Relocated value must be a pointer type, but gc_relocate does not need to return the + // same pointer type as the relocated pointer. It can be casted to the correct type later + // if it's desired. However, they must have the same address space. + GCRelocateOperands Operands(&CI); + Assert(Operands.getDerivedPtr()->getType()->isPointerTy(), + "gc.relocate: relocated value must be a gc pointer", &CI); + + // gc_relocate return type must be a pointer type, and is verified earlier in + // VerifyIntrinsicType(). + Assert(cast(CI.getType())->getAddressSpace() == + cast(Operands.getDerivedPtr()->getType())->getAddressSpace(), + "gc.relocate: relocating a pointer shouldn't change its address space", &CI); break; } }; -- cgit v1.2.3