summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorChen Li <meloli87@gmail.com>2015-05-18 19:50:14 +0000
committerChen Li <meloli87@gmail.com>2015-05-18 19:50:14 +0000
commit6d8635a74343d3ed7d19cb63edd4e508e9218fb4 (patch)
tree9bd2481501394de8e5d2f1d93ececd11cbb3b192 /llvm/lib/IR/Verifier.cpp
parent170ccd290d6e19b89c1246226678f82e2d1c2bf4 (diff)
downloadbcm5719-llvm-6d8635a74343d3ed7d19cb63edd4e508e9218fb4.tar.gz
bcm5719-llvm-6d8635a74343d3ed7d19cb63edd4e508e9218fb4.zip
[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
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp14
1 files changed, 12 insertions, 2 deletions
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<PointerType>(CI.getType())->getAddressSpace() ==
+ cast<PointerType>(Operands.getDerivedPtr()->getType())->getAddressSpace(),
+ "gc.relocate: relocating a pointer shouldn't change its address space", &CI);
break;
}
};
OpenPOWER on IntegriCloud