LLVM  15.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 using namespace llvm;
17 
19  return Attr.hasAttribute("statepoint-id") ||
20  Attr.hasAttribute("statepoint-num-patch-bytes");
21 }
22 
25  StatepointDirectives Result;
26 
27  Attribute AttrID = AS.getFnAttr("statepoint-id");
28  uint64_t StatepointID;
29  if (AttrID.isStringAttribute())
30  if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
31  Result.StatepointID = StatepointID;
32 
33  uint32_t NumPatchBytes;
34  Attribute AttrNumPatchBytes = AS.getFnAttr("statepoint-num-patch-bytes");
35  if (AttrNumPatchBytes.isStringAttribute())
36  if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
37  Result.NumPatchBytes = NumPatchBytes;
38 
39  return Result;
40 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::Attribute::hasAttribute
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:320
llvm::Attribute
Definition: Attributes.h:52
llvm::AttributeList
Definition: Attributes.h:408
llvm::Attribute::isStringAttribute
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:269
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:305
llvm::StringRef::getAsInteger
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:510
Statepoint.h
llvm::isStatepointDirectiveAttr
bool isStatepointDirectiveAttr(Attribute Attr)
Return true if the Attr is an attribute that is a statepoint directive.
Definition: Statepoint.cpp:18
uint64_t
llvm::StatepointDirectives
Call sites that get wrapped by a gc.statepoint (currently only in RewriteStatepointsForGC and potenti...
Definition: Statepoint.h:236
uint32_t
llvm::parseStatepointDirectivesFromAttrs
StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeList AS)
Parse out statepoint directives from the function attributes present in AS.
Definition: Statepoint.cpp:24
llvm::AttributeList::getFnAttr
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:793