1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "llvm/IR/Function.h"
14 #include "llvm/IR/Constant.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/IR/Statepoint.h"
17 #include "llvm/Support/CommandLine.h"
22 bool llvm::isStatepoint(const ImmutableCallSite &CS) {
23 if (!CS.getInstruction()) {
24 // This is not a call site
28 const Function *F = CS.getCalledFunction();
29 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
31 bool llvm::isStatepoint(const Value *inst) {
32 if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
33 ImmutableCallSite CS(inst);
34 return isStatepoint(CS);
38 bool llvm::isStatepoint(const Value &inst) {
39 return isStatepoint(&inst);
42 bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
43 if (!CS.getInstruction()) {
44 // This is not a call site
48 return isGCRelocate(CS.getInstruction());
50 bool llvm::isGCRelocate(const Value *inst) {
51 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
52 if (const Function *F = call->getCalledFunction()) {
53 return F->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
59 bool llvm::isGCResult(const ImmutableCallSite &CS) {
60 if (!CS.getInstruction()) {
61 // This is not a call site
65 return isGCResult(CS.getInstruction());
67 bool llvm::isGCResult(const Value *inst) {
68 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
69 if (Function *F = call->getCalledFunction()) {
70 return (F->getIntrinsicID() == Intrinsic::experimental_gc_result_int ||
71 F->getIntrinsicID() == Intrinsic::experimental_gc_result_float ||
72 F->getIntrinsicID() == Intrinsic::experimental_gc_result_ptr ||
73 F->getIntrinsicID() == Intrinsic::experimental_gc_result);