LLVM  12.0.0git
Statepoint.cpp
Go to the documentation of this file.
1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains some utility functions to help recognize gc.statepoint
10 // intrinsics.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/Statepoint.h"
15 
16 #include "llvm/IR/Function.h"
17 
18 using namespace llvm;
19 
21  return Attr.hasAttribute("statepoint-id") ||
22  Attr.hasAttribute("statepoint-num-patch-bytes");
23 }
24 
27  StatepointDirectives Result;
28 
29  Attribute AttrID =
30  AS.getAttribute(AttributeList::FunctionIndex, "statepoint-id");
31  uint64_t StatepointID;
32  if (AttrID.isStringAttribute())
33  if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
34  Result.StatepointID = StatepointID;
35 
36  uint32_t NumPatchBytes;
38  "statepoint-num-patch-bytes");
39  if (AttrNumPatchBytes.isStringAttribute())
40  if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
41  Result.NumPatchBytes = NumPatchBytes;
42 
43  return Result;
44 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeList AS)
Parse out statepoint directives from the function attributes present in AS.
Definition: Statepoint.cpp:26
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:238
std::enable_if_t< std::numeric_limits< T >::is_signed, bool > getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:511
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:282
Optional< uint32_t > NumPatchBytes
Definition: Statepoint.h:375
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool isStatepointDirectiveAttr(Attribute Attr)
Return true if the Attr is an attribute that is a statepoint directive.
Definition: Statepoint.cpp:20
Optional< uint64_t > StatepointID
Definition: Statepoint.h:376
Call sites that get wrapped by a gc.statepoint (currently only in RewriteStatepointsForGC and potenti...
Definition: Statepoint.h:374
StringRef getValueAsString() const
Return the attribute&#39;s value as a string.
Definition: Attributes.cpp:267