LLVM  3.7.0
Statepoint.cpp
Go to the documentation of this file.
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"
18 
19 using namespace std;
20 using namespace llvm;
21 
23  if (!CS.getInstruction()) {
24  // This is not a call site
25  return false;
26  }
27 
28  const Function *F = CS.getCalledFunction();
29  return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
30 }
31 bool llvm::isStatepoint(const Value *inst) {
32  if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
33  ImmutableCallSite CS(inst);
34  return isStatepoint(CS);
35  }
36  return false;
37 }
38 bool llvm::isStatepoint(const Value &inst) {
39  return isStatepoint(&inst);
40 }
41 
43  if (!CS.getInstruction()) {
44  // This is not a call site
45  return false;
46  }
47 
48  return isGCRelocate(CS.getInstruction());
49 }
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;
54  }
55  }
56  return false;
57 }
58 
60  if (!CS.getInstruction()) {
61  // This is not a call site
62  return false;
63  }
64 
65  return isGCResult(CS.getInstruction());
66 }
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);
74  }
75  }
76  return false;
77 }
InstrTy * getInstruction() const
Definition: CallSite.h:82
CallInst - This class represents a function call, abstracting a target machine's calling convention...
F(f)
bool isStatepoint(const ImmutableCallSite &CS)
Definition: Statepoint.cpp:22
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
Definition: CallSite.h:99
bool isGCRelocate(const Value *V)
Definition: Statepoint.cpp:50
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:159
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:418
LLVM Value Representation.
Definition: Value.h:69
bool isGCResult(const Value *V)
Definition: Statepoint.cpp:67