blob: e56da6beaff05e04a52f50dfacb49e8e312008d5 [file] [log] [blame]
Philip Reames1a1bdb22014-12-02 18:50:36 +00001//===-- 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//
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000010// This file contains some utility functions to help recognize gc.statepoint
11// intrinsics.
12//
Philip Reames1a1bdb22014-12-02 18:50:36 +000013//===----------------------------------------------------------------------===//
14
Philip Reames1a1bdb22014-12-02 18:50:36 +000015#include "llvm/IR/Statepoint.h"
16
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000017#include "llvm/IR/Function.h"
18
Philip Reames1a1bdb22014-12-02 18:50:36 +000019using namespace llvm;
20
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000021static const Function *getCalledFunction(ImmutableCallSite CS) {
22 if (!CS.getInstruction())
23 return nullptr;
24 return CS.getCalledFunction();
Philip Reames1a1bdb22014-12-02 18:50:36 +000025}
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000026
27bool llvm::isStatepoint(ImmutableCallSite CS) {
28 if (auto *F = getCalledFunction(CS))
29 return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint;
Philip Reames1a1bdb22014-12-02 18:50:36 +000030 return false;
31}
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000032
33bool llvm::isStatepoint(const Value *V) {
34 if (auto CS = ImmutableCallSite(V))
35 return isStatepoint(CS);
36 return false;
Philip Reames1a1bdb22014-12-02 18:50:36 +000037}
38
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000039bool llvm::isStatepoint(const Value &V) {
40 return isStatepoint(&V);
41}
42
43bool llvm::isGCRelocate(ImmutableCallSite CS) {
Manuel Jacob83eefa62016-01-05 04:03:00 +000044 return CS.getInstruction() && isa<GCRelocateInst>(CS.getInstruction());
Philip Reames1a1bdb22014-12-02 18:50:36 +000045}
46
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000047bool llvm::isGCResult(ImmutableCallSite CS) {
48 if (auto *F = getCalledFunction(CS))
49 return F->getIntrinsicID() == Intrinsic::experimental_gc_result;
Philip Reames1a1bdb22014-12-02 18:50:36 +000050 return false;
51}
Sanjoy Dasd6fc46e2016-03-17 00:47:18 +000052
53bool llvm::isGCResult(const Value *V) {
54 return isGCResult(ImmutableCallSite(V));
55}