LLVM  8.0.1
Macros | 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/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 "AttributesCompatFunc.inc"
Include dependency graph for Attributes.cpp:

Go to the source code of this file.

Macros

#define GET_ATTR_COMPAT_FUNC
 

Functions

static uint64_t packAllocSizeArgs (unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
 
static std::pair< unsigned, Optional< unsigned > > unpackAllocSizeArgs (uint64_t Num)
 
static constexpr 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=true" attribute, set this attribute in the caller post inlining. More...
 

Variables

static const unsigned AllocSizeNumElemsNotPresent = -1
 

Macro Definition Documentation

◆ GET_ATTR_COMPAT_FUNC

#define GET_ATTR_COMPAT_FUNC

Definition at line 1727 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 1632 of file Attributes.cpp.

References llvm::AttrBuilder::addAttribute(), llvm::Function::addFnAttr(), llvm::AttributeList::FunctionIndex, llvm::Function::hasFnAttribute(), llvm::Function::removeAttributes(), llvm::Attribute::StackProtect, llvm::Attribute::StackProtectReq, and llvm::Attribute::StackProtectStrong.

◆ 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 1656 of file Attributes.cpp.

References llvm::Function::addFnAttr(), llvm::Function::getFnAttribute(), and llvm::Function::hasFnAttribute().

◆ 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 1667 of file Attributes.cpp.

References llvm::Function::addFnAttr(), llvm::StringRef::getAsInteger(), llvm::Function::getFnAttribute(), llvm::Attribute::getValueAsString(), and llvm::Function::hasFnAttribute().

◆ 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 1697 of file Attributes.cpp.

References llvm::Function::addFnAttr(), llvm::StringRef::getAsInteger(), llvm::Function::getFnAttribute(), llvm::Attribute::getValueAsString(), llvm::Function::hasFnAttribute(), and llvm::Function::removeFnAttr().

◆ adjustNullPointerValidAttr()

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

If the inlined function has "null-pointer-is-valid=true" attribute, set this attribute in the caller post inlining.

Definition at line 1721 of file Attributes.cpp.

References llvm::Function::addFnAttr(), llvm::Function::getFnAttribute(), and llvm::Function::nullPointerIsDefined().

◆ attrIdxToArrayIdx()

static constexpr unsigned attrIdxToArrayIdx ( unsigned  Index)
static

Map from AttributeList index to the internal array index.

Adding one happens to work, but it relies on unsigned integer wrapping. MSVC warns about unsigned wrapping in constexpr functions, so write out the conditional. LLVM folds it to add anyway.

Definition at line 802 of file Attributes.cpp.

References llvm::AttributeList::FunctionIndex.

Referenced by llvm::AttributeList::addAttributes(), llvm::AttributeList::addParamAttribute(), llvm::AttributeListImpl::AttributeListImpl(), llvm::AttributeList::get(), llvm::AttributeList::getAttributes(), llvm::AttributeList::removeAttribute(), and llvm::AttributeList::removeAttributes().

◆ isEqual()

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

Definition at line 1601 of file Attributes.cpp.

References llvm::Function::getFnAttribute().

Referenced by llvm::ImutAVLFactory< ImutInfo >::add_internal(), llvm::DenseMapBase< DenseMap< const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >, const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >::clear(), llvm::DenseMapBase< DenseMap< const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >, const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >::copyFrom(), DeleteTriviallyDeadInstructions(), llvm::DenseMapBase< DenseMap< const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >, const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >::destroyAll(), llvm::GVNExpression::Expression::dump(), llvm::EliminateDuplicatePHINodes(), llvm::ImutAVLTree< ImutInfo >::find(), llvm::InnerLoopVectorizer::fixupIVUsers(), llvm::gatherUnrollingPreferences(), llvm::DenseMapInfo< CachedHashStringRef >::getHashValue(), llvm::DenseMapInfo< CachedHashString >::getHashValue(), llvm::DenseMapInfo< SimpleValue >::getTombstoneKey(), llvm::DenseMapInfo< CallValue >::getTombstoneKey(), llvm::DenseMapBase< DenseMap< const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >, const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >::getTombstoneKey(), llvm::SmallDenseMap< const llvm::DISubprogram *, detail::DenseSetEmpty, InlineBuckets, DenseMapInfo< const llvm::DISubprogram *>, detail::DenseSetPair< const llvm::DISubprogram * > >::grow(), llvm::slpvectorizer::BoUpSLP::BlockScheduling::ReadyList::insert(), llvm::ImutAVLTree< ImutInfo >::isElementEqual(), llvm::DenseMapInfo< CachedHashStringRef >::isEqual(), llvm::DenseMapInfo< BasicBlockEdge >::isEqual(), llvm::DenseMapInfo< std::pair< T, U > >::isEqual(), llvm::DenseMapInfo< AssertingVH< T > >::isEqual(), llvm::DenseMapInfo< PointerUnion< T, U > >::isEqual(), llvm::DenseMapInfo< PoisoningVH< T > >::isEqual(), llvm::DenseMapInfo< FunctionSummary::ConstVCall >::isEqual(), llvm::DenseMapInfo< TargetInstrInfo::RegSubRegPair >::isEqual(), llvm::DWARFDebugNames::SentinelError::log(), markAliveBlocks(), llvm::DenseMapBase< DenseMap< const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >, const llvm::SCEV *, const llvm::SCEV *, DenseMapInfo< const llvm::SCEV *>, llvm::detail::DenseMapPair< const llvm::SCEV *, const llvm::SCEV *> >::moveFromOldBuckets(), llvm::IRMover::StructTypeKeyInfo::KeyTy::operator!=(), llvm::DenseMapIterator< KeyT, ValueT, KeyInfoT, Bucket, IsConst >::operator++(), llvm::ImmutableList< T >::operator==(), llvm::ImutAVLFactory< ImutInfo >::remove_internal(), and llvm::SmallDenseMap< const llvm::DISubprogram *, detail::DenseSetEmpty, InlineBuckets, DenseMapInfo< const llvm::DISubprogram *>, detail::DenseSetPair< const llvm::DISubprogram * > >::swap().

◆ packAllocSizeArgs()

static uint64_t packAllocSizeArgs ( unsigned  ElemSizeArg,
const Optional< unsigned > &  NumElemsArg 
)
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 1612 of file Attributes.cpp.

◆ 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 1624 of file Attributes.cpp.

◆ unpackAllocSizeArgs()

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

Definition at line 71 of file Attributes.cpp.

References llvm::max().

Referenced by llvm::Attribute::getAllocSizeArgs(), and llvm::AttrBuilder::getAllocSizeArgs().

Variable Documentation

◆ AllocSizeNumElemsNotPresent

const unsigned AllocSizeNumElemsNotPresent = -1
static

Definition at line 58 of file Attributes.cpp.

Referenced by packAllocSizeArgs().