LLVM  14.0.0git
Classes | Macros | Enumerations | Functions | Variables
Attributes.cpp File Reference
#include "llvm/IR/Attributes.h"
#include "AttributeImpl.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>
#include <tuple>
#include <utility>
#include "llvm/IR/Attributes.inc"
Include dependency graph for Attributes.cpp:

Go to the source code of this file.

Classes

struct  EnumAttr
 
struct  StrBoolAttr
 

Macros

#define GET_ATTR_NAMES
 
#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME)   .Case(#DISPLAY_NAME, Attribute::ENUM_NAME)
 
#define GET_ATTR_NAMES
 
#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME)
 
#define GET_ATTR_NAMES
 
#define ATTRIBUTE_ALL(ENUM_NAME, DISPLAY_NAME)   .Case(#DISPLAY_NAME, true)
 
#define GET_ATTR_PROP_TABLE
 
#define GET_ATTR_NAMES
 
#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME)
 
#define ATTRIBUTE_STRBOOL(ENUM_NAME, DISPLAY_NAME)
 
#define GET_ATTR_COMPAT_FUNC
 

Enumerations

enum  AttributeProperty { FnAttr = (1 << 0), ParamAttr = (1 << 1), RetAttr = (1 << 2) }
 

Functions

static uint64_t packAllocSizeArgs (unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
 
static std::pair< unsigned, Optional< unsigned > > unpackAllocSizeArgs (uint64_t Num)
 
static uint64_t packVScaleRangeArgs (unsigned MinValue, unsigned MaxValue)
 
static std::pair< unsigned, unsigned > unpackVScaleRangeArgs (uint64_t Value)
 
static bool hasAttributeProperty (Attribute::AttrKind Kind, AttributeProperty Prop)
 
static unsigned attrIdxToArrayIdx (unsigned Index)
 Map from AttributeList index to the internal array index. More...
 
template<typename AttrClass >
static bool isEqual (const Function &Caller, const Function &Callee)
 
template<typename AttrClass >
static void setAND (Function &Caller, const Function &Callee)
 Compute the logical AND of the attributes of the caller and the callee. More...
 
template<typename AttrClass >
static void setOR (Function &Caller, const Function &Callee)
 Compute the logical OR of the attributes of the caller and the callee. More...
 
static void adjustCallerSSPLevel (Function &Caller, const Function &Callee)
 If the inlined function had a higher stack protection level than the calling function, then bump up the caller's stack protection level. More...
 
static void adjustCallerStackProbes (Function &Caller, const Function &Callee)
 If the inlined function required stack probes, then ensure that the calling function has those too. More...
 
static void adjustCallerStackProbeSize (Function &Caller, const Function &Callee)
 If the inlined function defines the size of guard region on the stack, then ensure that the calling function defines a guard region that is no larger. More...
 
static void adjustMinLegalVectorWidth (Function &Caller, const Function &Callee)
 If the inlined function defines a min legal vector width, then ensure the calling function has the same or larger min legal vector width. More...
 
static void adjustNullPointerValidAttr (Function &Caller, const Function &Callee)
 If the inlined function has null_pointer_is_valid attribute, set this attribute in the caller post inlining. More...
 

Variables

static const unsigned AllocSizeNumElemsNotPresent = -1
 

Macro Definition Documentation

◆ ATTRIBUTE_ALL

#define ATTRIBUTE_ALL (   ENUM_NAME,
  DISPLAY_NAME 
)    .Case(#DISPLAY_NAME, true)

◆ ATTRIBUTE_ENUM [1/3]

#define ATTRIBUTE_ENUM (   ENUM_NAME,
  DISPLAY_NAME 
)    .Case(#DISPLAY_NAME, Attribute::ENUM_NAME)

Definition at line 2085 of file Attributes.cpp.

◆ ATTRIBUTE_ENUM [2/3]

#define ATTRIBUTE_ENUM (   ENUM_NAME,
  DISPLAY_NAME 
)
Value:
case Attribute::ENUM_NAME: \
return #DISPLAY_NAME;

Definition at line 2085 of file Attributes.cpp.

◆ ATTRIBUTE_ENUM [3/3]

#define ATTRIBUTE_ENUM (   ENUM_NAME,
  DISPLAY_NAME 
)
Value:
struct ENUM_NAME##Attr : EnumAttr { \
static enum Attribute::AttrKind getKind() { \
return llvm::Attribute::ENUM_NAME; \
} \
};

Definition at line 2085 of file Attributes.cpp.

◆ ATTRIBUTE_STRBOOL

#define ATTRIBUTE_STRBOOL (   ENUM_NAME,
  DISPLAY_NAME 
)
Value:
struct ENUM_NAME##Attr : StrBoolAttr { \
static StringRef getKind() { return #DISPLAY_NAME; } \
};

Definition at line 2091 of file Attributes.cpp.

◆ GET_ATTR_COMPAT_FUNC

#define GET_ATTR_COMPAT_FUNC

Definition at line 2097 of file Attributes.cpp.

◆ GET_ATTR_NAMES [1/4]

#define GET_ATTR_NAMES

Definition at line 2084 of file Attributes.cpp.

◆ GET_ATTR_NAMES [2/4]

#define GET_ATTR_NAMES

Definition at line 2084 of file Attributes.cpp.

◆ GET_ATTR_NAMES [3/4]

#define GET_ATTR_NAMES

Definition at line 2084 of file Attributes.cpp.

◆ GET_ATTR_NAMES [4/4]

#define GET_ATTR_NAMES

Definition at line 2084 of file Attributes.cpp.

◆ GET_ATTR_PROP_TABLE

#define GET_ATTR_PROP_TABLE

Definition at line 494 of file Attributes.cpp.

Enumeration Type Documentation

◆ AttributeProperty

Enumerator
FnAttr 
ParamAttr 
RetAttr 

Definition at line 488 of file Attributes.cpp.

Function Documentation

◆ adjustCallerSSPLevel()

static void adjustCallerSSPLevel ( Function Caller,
const Function Callee 
)
static

If the inlined function had a higher stack protection level than the calling function, then bump up the caller's stack protection level.

Definition at line 1966 of file Attributes.cpp.

References llvm::AttrBuilder::addAttribute(), and Callee.

◆ adjustCallerStackProbes()

static void adjustCallerStackProbes ( Function Caller,
const Function Callee 
)
static

If the inlined function required stack probes, then ensure that the calling function has those too.

Definition at line 1990 of file Attributes.cpp.

References Callee.

◆ adjustCallerStackProbeSize()

static void adjustCallerStackProbeSize ( Function Caller,
const Function Callee 
)
static

If the inlined function defines the size of guard region on the stack, then ensure that the calling function defines a guard region that is no larger.

Definition at line 2001 of file Attributes.cpp.

References Callee, llvm::StringRef::getAsInteger(), llvm::Attribute::getValueAsString(), and llvm::Attribute::isValid().

◆ adjustMinLegalVectorWidth()

static void adjustMinLegalVectorWidth ( Function Caller,
const Function Callee 
)
static

If the inlined function defines a min legal vector width, then ensure the calling function has the same or larger min legal vector width.

If the caller has the attribute, but the callee doesn't, we need to remove the attribute from the caller since we can't make any guarantees about the caller's requirements. This function is called after the inlining decision has been made so we have to merge the attribute this way. Heuristics that would use min-legal-vector-width to determine inline compatibility would need to be handled as part of inline cost analysis.

Definition at line 2029 of file Attributes.cpp.

References Callee, llvm::StringRef::getAsInteger(), llvm::Attribute::getValueAsString(), and llvm::Attribute::isValid().

◆ adjustNullPointerValidAttr()

static void adjustNullPointerValidAttr ( Function Caller,
const Function Callee 
)
static

If the inlined function has null_pointer_is_valid attribute, set this attribute in the caller post inlining.

Definition at line 2050 of file Attributes.cpp.

References Callee.

◆ attrIdxToArrayIdx()

static unsigned attrIdxToArrayIdx ( unsigned  Index)
static

Map from AttributeList index to the internal array index.

Adding one happens to work, because -1 wraps around to 0.

Definition at line 951 of file Attributes.cpp.

References Index.

Referenced by llvm::AttributeList::addParamAttribute(), llvm::AttributeListImpl::AttributeListImpl(), llvm::AttributeList::get(), llvm::AttributeList::getAttributes(), llvm::AttributeList::removeAttributeAtIndex(), and llvm::AttributeList::removeAttributesAtIndex().

◆ hasAttributeProperty()

static bool hasAttributeProperty ( Attribute::AttrKind  Kind,
AttributeProperty  Prop 
)
static

◆ isEqual()

template<typename AttrClass >
static bool isEqual ( const Function Caller,
const Function Callee 
)
static

Definition at line 1935 of file Attributes.cpp.

References Callee.

Referenced by llvm::ImutAVLFactory< ImutInfo >::add_internal(), llvm::DenseMapBase< SmallDenseMap< llvm::Value *, int, 4, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >, llvm::Value *, int, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >::clear(), llvm::DenseMapBase< SmallDenseMap< llvm::Value *, int, 4, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >, llvm::Value *, int, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >::copyFrom(), llvm::DenseMapBase< SmallDenseMap< llvm::Value *, int, 4, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >, llvm::Value *, int, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >::destroyAll(), llvm::ImutAVLTree< ImutInfo >::find(), llvm::SmallDenseMap< llvm::Value *, llvm::Value * >::grow(), llvm::ImutAVLTree< ImutInfo >::isElementEqual(), llvm::DenseMapInfo< CachedHashStringRef >::isEqual(), llvm::DenseMapInfo< MCRegister >::isEqual(), llvm::DenseMapInfo< BasicBlockEdge >::isEqual(), llvm::DenseMapInfo< Register >::isEqual(), llvm::DenseMapInfo< WeakVH >::isEqual(), llvm::DenseMapInfo< std::pair< T, U > >::isEqual(), llvm::DenseMapInfo< PoisoningVH< T > >::isEqual(), llvm::DenseMapInfo< FunctionSummary::ConstVCall >::isEqual(), llvm::DenseMapInfo< TargetInstrInfo::RegSubRegPair >::isEqual(), llvm::DenseMapInfo< std::tuple< Ts... > >::isEqualImpl(), llvm::DenseMapBase< SmallDenseMap< llvm::Value *, int, 4, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >, llvm::Value *, int, DenseMapInfo< llvm::Value * >, llvm::detail::DenseMapPair< llvm::Value *, int > >::moveFromOldBuckets(), llvm::rdf::RegisterAggr::operator==(), llvm::ImutAVLFactory< ImutInfo >::remove_internal(), and llvm::SmallDenseMap< llvm::Value *, llvm::Value * >::swap().

◆ packAllocSizeArgs()

static uint64_t packAllocSizeArgs ( unsigned  ElemSizeArg,
const Optional< unsigned > &  NumElemsArg 
)
static

◆ packVScaleRangeArgs()

static uint64_t packVScaleRangeArgs ( unsigned  MinValue,
unsigned  MaxValue 
)
static

◆ setAND()

template<typename AttrClass >
static void setAND ( Function Caller,
const Function Callee 
)
static

Compute the logical AND of the attributes of the caller and the callee.

This function sets the caller's attribute to false if the callee's attribute is false.

Definition at line 1946 of file Attributes.cpp.

References Callee, and set.

◆ setOR()

template<typename AttrClass >
static void setOR ( Function Caller,
const Function Callee 
)
static

Compute the logical OR of the attributes of the caller and the callee.

This function sets the caller's attribute to true if the callee's attribute is true.

Definition at line 1958 of file Attributes.cpp.

References Callee, and set.

◆ unpackAllocSizeArgs()

static std::pair<unsigned, Optional<unsigned> > unpackAllocSizeArgs ( uint64_t  Num)
static

◆ unpackVScaleRangeArgs()

static std::pair<unsigned, unsigned> unpackVScaleRangeArgs ( uint64_t  Value)
static

Variable Documentation

◆ AllocSizeNumElemsNotPresent

const unsigned AllocSizeNumElemsNotPresent = -1
static

Definition at line 58 of file Attributes.cpp.

Referenced by packAllocSizeArgs(), and unpackAllocSizeArgs().

StrBoolAttr
Definition: Attributes.cpp:2071
EnumAttr
Definition: Attributes.cpp:2056
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:71
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58