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 const Function *F = CS.getCalledFunction();
24 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
26 bool llvm::isStatepoint(const Instruction *inst) {
27 if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
28 ImmutableCallSite CS(inst);
29 return isStatepoint(CS);
33 bool llvm::isStatepoint(const Instruction &inst) {
34 return isStatepoint(&inst);
37 bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
38 return isGCRelocate(CS.getInstruction());
40 bool llvm::isGCRelocate(const Instruction *inst) {
41 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
42 if (const Function *F = call->getCalledFunction()) {
43 return F->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
49 bool llvm::isGCResult(const ImmutableCallSite &CS) {
50 return isGCResult(CS.getInstruction());
52 bool llvm::isGCResult(const Instruction *inst) {
53 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
54 if (Function *F = call->getCalledFunction()) {
55 return (F->getIntrinsicID() == Intrinsic::experimental_gc_result_int ||
56 F->getIntrinsicID() == Intrinsic::experimental_gc_result_float ||
57 F->getIntrinsicID() == Intrinsic::experimental_gc_result_ptr);