annotate llvm/lib/IR/Statepoint.cpp @ 220:42394fc6a535

Added tag llvm12 for changeset 0572611fdcc8
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:13:43 +0900
parents 1d019706d866
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This file contains some utility functions to help recognize gc.statepoint
anatofuz
parents:
diff changeset
10 // intrinsics.
anatofuz
parents:
diff changeset
11 //
anatofuz
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 #include "llvm/IR/Statepoint.h"
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 #include "llvm/IR/Function.h"
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 using namespace llvm;
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 bool llvm::isStatepoint(const CallBase *Call) {
anatofuz
parents:
diff changeset
21 if (auto *F = Call->getCalledFunction())
anatofuz
parents:
diff changeset
22 return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint;
anatofuz
parents:
diff changeset
23 return false;
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 bool llvm::isStatepoint(const Value *V) {
anatofuz
parents:
diff changeset
27 if (auto *Call = dyn_cast<CallBase>(V))
anatofuz
parents:
diff changeset
28 return isStatepoint(Call);
anatofuz
parents:
diff changeset
29 return false;
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 bool llvm::isStatepoint(const Value &V) {
anatofuz
parents:
diff changeset
33 return isStatepoint(&V);
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 bool llvm::isGCRelocate(const CallBase *Call) {
anatofuz
parents:
diff changeset
37 return isa<GCRelocateInst>(Call);
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 bool llvm::isGCRelocate(const Value *V) {
anatofuz
parents:
diff changeset
41 if (auto *Call = dyn_cast<CallBase>(V))
anatofuz
parents:
diff changeset
42 return isGCRelocate(Call);
anatofuz
parents:
diff changeset
43 return false;
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 bool llvm::isGCResult(const CallBase *Call) { return isa<GCResultInst>(Call); }
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 bool llvm::isGCResult(const Value *V) {
anatofuz
parents:
diff changeset
49 if (auto *Call = dyn_cast<CallBase>(V))
anatofuz
parents:
diff changeset
50 return isGCResult(Call);
anatofuz
parents:
diff changeset
51 return false;
anatofuz
parents:
diff changeset
52 }
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
anatofuz
parents:
diff changeset
55 return Attr.hasAttribute("statepoint-id") ||
anatofuz
parents:
diff changeset
56 Attr.hasAttribute("statepoint-num-patch-bytes");
anatofuz
parents:
diff changeset
57 }
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 StatepointDirectives
anatofuz
parents:
diff changeset
60 llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) {
anatofuz
parents:
diff changeset
61 StatepointDirectives Result;
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 Attribute AttrID =
anatofuz
parents:
diff changeset
64 AS.getAttribute(AttributeList::FunctionIndex, "statepoint-id");
anatofuz
parents:
diff changeset
65 uint64_t StatepointID;
anatofuz
parents:
diff changeset
66 if (AttrID.isStringAttribute())
anatofuz
parents:
diff changeset
67 if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
anatofuz
parents:
diff changeset
68 Result.StatepointID = StatepointID;
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 uint32_t NumPatchBytes;
anatofuz
parents:
diff changeset
71 Attribute AttrNumPatchBytes = AS.getAttribute(AttributeList::FunctionIndex,
anatofuz
parents:
diff changeset
72 "statepoint-num-patch-bytes");
anatofuz
parents:
diff changeset
73 if (AttrNumPatchBytes.isStringAttribute())
anatofuz
parents:
diff changeset
74 if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
anatofuz
parents:
diff changeset
75 Result.NumPatchBytes = NumPatchBytes;
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 return Result;
anatofuz
parents:
diff changeset
78 }