1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // 11 //===----------------------------------------------------------------------===// 12 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" 18 19 using namespace std; 20 using namespace llvm; 21 isStatepoint(const ImmutableCallSite & CS)22bool llvm::isStatepoint(const ImmutableCallSite &CS) { 23 const Function *F = CS.getCalledFunction(); 24 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint); 25 } isStatepoint(const Instruction * inst)26bool llvm::isStatepoint(const Instruction *inst) { 27 if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) { 28 ImmutableCallSite CS(inst); 29 return isStatepoint(CS); 30 } 31 return false; 32 } isStatepoint(const Instruction & inst)33bool llvm::isStatepoint(const Instruction &inst) { 34 return isStatepoint(&inst); 35 } 36 isGCRelocate(const ImmutableCallSite & CS)37bool llvm::isGCRelocate(const ImmutableCallSite &CS) { 38 return isGCRelocate(CS.getInstruction()); 39 } isGCRelocate(const Instruction * inst)40bool 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; 44 } 45 } 46 return false; 47 } 48 isGCResult(const ImmutableCallSite & CS)49bool llvm::isGCResult(const ImmutableCallSite &CS) { 50 return isGCResult(CS.getInstruction()); 51 } isGCResult(const Instruction * inst)52bool 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); 58 } 59 } 60 return false; 61 } 62