Mercurial > hg > CbC > CbC_llvm
comparison lib/IR/Statepoint.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
comparison
equal
deleted
inserted
replaced
146:3fc4d5c3e21e | 148:63bd29f05246 |
---|---|
1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===// | 1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // This file contains some utility functions to help recognize gc.statepoint | 9 // This file contains some utility functions to help recognize gc.statepoint |
11 // intrinsics. | 10 // intrinsics. |
16 | 15 |
17 #include "llvm/IR/Function.h" | 16 #include "llvm/IR/Function.h" |
18 | 17 |
19 using namespace llvm; | 18 using namespace llvm; |
20 | 19 |
21 static const Function *getCalledFunction(ImmutableCallSite CS) { | 20 bool llvm::isStatepoint(const CallBase *Call) { |
22 if (!CS.getInstruction()) | 21 if (auto *F = Call->getCalledFunction()) |
23 return nullptr; | |
24 return CS.getCalledFunction(); | |
25 } | |
26 | |
27 bool llvm::isStatepoint(ImmutableCallSite CS) { | |
28 if (auto *F = getCalledFunction(CS)) | |
29 return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint; | 22 return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint; |
30 return false; | 23 return false; |
31 } | 24 } |
32 | 25 |
33 bool llvm::isStatepoint(const Value *V) { | 26 bool llvm::isStatepoint(const Value *V) { |
34 if (auto CS = ImmutableCallSite(V)) | 27 if (auto *Call = dyn_cast<CallBase>(V)) |
35 return isStatepoint(CS); | 28 return isStatepoint(Call); |
36 return false; | 29 return false; |
37 } | 30 } |
38 | 31 |
39 bool llvm::isStatepoint(const Value &V) { | 32 bool llvm::isStatepoint(const Value &V) { |
40 return isStatepoint(&V); | 33 return isStatepoint(&V); |
41 } | 34 } |
42 | 35 |
43 bool llvm::isGCRelocate(ImmutableCallSite CS) { | 36 bool llvm::isGCRelocate(const CallBase *Call) { |
44 return CS.getInstruction() && isa<GCRelocateInst>(CS.getInstruction()); | 37 return isa<GCRelocateInst>(Call); |
45 } | 38 } |
46 | 39 |
47 bool llvm::isGCRelocate(const Value *V) { | 40 bool llvm::isGCRelocate(const Value *V) { |
48 if (auto CS = ImmutableCallSite(V)) | 41 if (auto *Call = dyn_cast<CallBase>(V)) |
49 return isGCRelocate(CS); | 42 return isGCRelocate(Call); |
50 return false; | 43 return false; |
51 } | 44 } |
52 | 45 |
53 bool llvm::isGCResult(ImmutableCallSite CS) { | 46 bool llvm::isGCResult(const CallBase *Call) { return isa<GCResultInst>(Call); } |
54 return CS.getInstruction() && isa<GCResultInst>(CS.getInstruction()); | |
55 } | |
56 | 47 |
57 bool llvm::isGCResult(const Value *V) { | 48 bool llvm::isGCResult(const Value *V) { |
58 if (auto CS = ImmutableCallSite(V)) | 49 if (auto *Call = dyn_cast<CallBase>(V)) |
59 return isGCResult(CS); | 50 return isGCResult(Call); |
60 return false; | 51 return false; |
61 } | 52 } |
62 | 53 |
63 bool llvm::isStatepointDirectiveAttr(Attribute Attr) { | 54 bool llvm::isStatepointDirectiveAttr(Attribute Attr) { |
64 return Attr.hasAttribute("statepoint-id") || | 55 return Attr.hasAttribute("statepoint-id") || |