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/Support/CommandLine.h"
18 #include "llvm/IR/Statepoint.h"
23 bool llvm::isStatepoint(const ImmutableCallSite &CS) {
24 const Function *F = CS.getCalledFunction();
25 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
27 bool llvm::isStatepoint(const Instruction *inst) {
28 if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
29 ImmutableCallSite CS(inst);
30 return isStatepoint(CS);
34 bool llvm::isStatepoint(const Instruction &inst) {
35 return isStatepoint(&inst);
38 bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
39 return isGCRelocate(CS.getInstruction());
41 bool llvm::isGCRelocate(const Instruction *inst) {
42 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
43 if (const Function *F = call->getCalledFunction()) {
44 return F->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
50 bool llvm::isGCResult(const ImmutableCallSite &CS) {
51 return isGCResult(CS.getInstruction());
53 bool llvm::isGCResult(const Instruction *inst) {
54 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
55 if (Function *F = call->getCalledFunction()) {
56 return (F->getIntrinsicID() == Intrinsic::experimental_gc_result_int ||
57 F->getIntrinsicID() == Intrinsic::experimental_gc_result_float ||
58 F->getIntrinsicID() == Intrinsic::experimental_gc_result_ptr);