summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Statepoint.cpp
blob: e56da6beaff05e04a52f50dfacb49e8e312008d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//===-- IR/Statepoint.cpp -- gc.statepoint utilities ---  -----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains some utility functions to help recognize gc.statepoint
// intrinsics.
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/Statepoint.h"

#include "llvm/IR/Function.h"

using namespace llvm;

static const Function *getCalledFunction(ImmutableCallSite CS) {
  if (!CS.getInstruction())
    return nullptr;
  return CS.getCalledFunction();
}

bool llvm::isStatepoint(ImmutableCallSite CS) {
  if (auto *F = getCalledFunction(CS))
    return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint;
  return false;
}

bool llvm::isStatepoint(const Value *V) {
  if (auto CS = ImmutableCallSite(V))
    return isStatepoint(CS);
  return false;
}

bool llvm::isStatepoint(const Value &V) {
  return isStatepoint(&V);
}

bool llvm::isGCRelocate(ImmutableCallSite CS) {
  return CS.getInstruction() && isa<GCRelocateInst>(CS.getInstruction());
}

bool llvm::isGCResult(ImmutableCallSite CS) {
  if (auto *F = getCalledFunction(CS))
    return F->getIntrinsicID() == Intrinsic::experimental_gc_result;
  return false;
}

bool llvm::isGCResult(const Value *V) {
  return isGCResult(ImmutableCallSite(V));
}
OpenPOWER on IntegriCloud