LLVM  13.0.0git
Classes | Namespaces | Macros | Functions | Variables
AttributorAttributes.cpp File Reference
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumeBundleQueries.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO/ArgumentPromotion.h"
#include "llvm/Transforms/Utils/Local.h"
#include <cassert>
Include dependency graph for AttributorAttributes.cpp:

Go to the source code of this file.

Classes

struct  AAReturnedFromReturnedValues< AAType, BaseType, StateType, PropagateCallBaseContext >
 Helper class for generic deduction: return value -> returned position. More...
 
struct  AAArgumentFromCallSiteArguments< AAType, BaseType, StateType, BridgeCallBaseContext >
 Helper class for generic deduction: call site argument -> argument position. More...
 
struct  AACallSiteReturnedFromReturned< AAType, BaseType, StateType, IntroduceCallBaseContext >
 Helper class for generic replication: function returned -> cs returned. More...
 
struct  llvm::DenseMapInfo< AAPointerInfo::Access >
 Helper for AA::PointerInfo::Acccess DenseMap/Set usage. More...
 
struct  llvm::DenseMapInfo< AA::PointerInfo ::OffsetAndSize >
 Helper that allows OffsetAndSize as a key in a DenseMap. More...
 
struct  llvm::AccessAsInstructionInfo
 Helper for AA::PointerInfo::Acccess DenseMap/Set usage ignoring everythign but the instruction. More...
 
struct  llvm::AA::PointerInfo::OffsetAndSize
 Helper to represent an access offset and size, with logic to deal with uncertainty and check for overlapping accesses. More...
 
struct  llvm::AA::PointerInfo::State
 } More...
 
struct  AAPointerInfoImpl
 
struct  AAPointerInfoFloating
 
struct  AAPointerInfoReturned
 
struct  AAPointerInfoArgument
 
struct  AAPointerInfoCallSiteArgument
 
struct  AAPointerInfoCallSiteReturned
 
struct  AANoUnwindImpl
 --------------------—NoUnwind Function Attribute-----------------------— More...
 
struct  AANoUnwindFunction
 
struct  AANoUnwindCallSite
 NoUnwind attribute deduction for a call sites. More...
 
class  AAReturnedValuesImpl
 ------------------— Function Return Values ----------------------------— More...
 
struct  AAReturnedValuesFunction
 
struct  AAReturnedValuesCallSite
 Returned values information for a call sites. More...
 
struct  AANoSyncImpl
 ---------------------— NoSync Function Attribute ----------------------— More...
 
struct  AANoSyncFunction
 
struct  AANoSyncCallSite
 NoSync attribute deduction for a call sites. More...
 
struct  AANoFreeImpl
 ---------------------— No-Free Attributes -------------------------— More...
 
struct  AANoFreeFunction
 
struct  AANoFreeCallSite
 NoFree attribute deduction for a call sites. More...
 
struct  AANoFreeFloating
 NoFree attribute for floating values. More...
 
struct  AANoFreeArgument
 NoFree attribute for a call site argument. More...
 
struct  AANoFreeCallSiteArgument
 NoFree attribute for call site arguments. More...
 
struct  AANoFreeReturned
 NoFree attribute for function return value. More...
 
struct  AANoFreeCallSiteReturned
 NoFree attribute deduction for a call site return value. More...
 
struct  AANonNullImpl
 
struct  AANonNullFloating
 NonNull attribute for a floating value. More...
 
struct  AANonNullReturned
 NonNull attribute for function return value. More...
 
struct  AANonNullArgument
 NonNull attribute for function argument. More...
 
struct  AANonNullCallSiteArgument
 
struct  AANonNullCallSiteReturned
 NonNull attribute for a call site return position. More...
 
struct  AANoRecurseImpl
 ---------------------— No-Recurse Attributes -------------------------— More...
 
struct  AANoRecurseFunction
 
struct  AANoRecurseCallSite
 NoRecurse attribute deduction for a call sites. More...
 
struct  AAUndefinedBehaviorImpl
 -----------------— Undefined-Behavior Attributes ---------------------— More...
 
struct  AAUndefinedBehaviorFunction
 
struct  AAWillReturnImpl
 
struct  AAWillReturnFunction
 
struct  AAWillReturnCallSite
 WillReturn attribute deduction for a call sites. More...
 
struct  AAReachabilityImpl
 ----------------—AAReachability Attribute-----------------------— More...
 
struct  AAReachabilityFunction
 
struct  AANoAliasImpl
 ---------------------— NoAlias Argument Attribute ---------------------— More...
 
struct  AANoAliasFloating
 NoAlias attribute for a floating value. More...
 
struct  AANoAliasArgument
 NoAlias attribute for an argument. More...
 
struct  AANoAliasCallSiteArgument
 
struct  AANoAliasReturned
 NoAlias attribute for function return value. More...
 
struct  AANoAliasCallSiteReturned
 NoAlias attribute deduction for a call site return value. More...
 
struct  AAIsDeadValueImpl
 ----------------—AAIsDead Function Attribute--------------------— More...
 
struct  AAIsDeadFloating
 
struct  AAIsDeadArgument
 
struct  AAIsDeadCallSiteArgument
 
struct  AAIsDeadCallSiteReturned
 
struct  AAIsDeadReturned
 
struct  AAIsDeadFunction
 
struct  AAIsDeadCallSite
 Liveness information for a call sites. More...
 
struct  AADereferenceableImpl
 -----------------— Dereferenceable Argument Attribute -----------------— More...
 
struct  AADereferenceableFloating
 Dereferenceable attribute for a floating value. More...
 
struct  AADereferenceableReturned
 Dereferenceable attribute for a return value. More...
 
struct  AADereferenceableArgument
 Dereferenceable attribute for an argument. More...
 
struct  AADereferenceableCallSiteArgument
 Dereferenceable attribute for a call site argument. More...
 
struct  AADereferenceableCallSiteReturned
 Dereferenceable attribute deduction for a call site return value. More...
 
struct  AAAlignImpl
 
struct  AAAlignFloating
 Align attribute for a floating value. More...
 
struct  AAAlignReturned
 Align attribute for function return value. More...
 
struct  AAAlignArgument
 Align attribute for function argument. More...
 
struct  AAAlignCallSiteArgument
 
struct  AAAlignCallSiteReturned
 Align attribute deduction for a call site return value. More...
 
struct  AANoReturnImpl
 ---------------— Function No-Return Attribute -------------------------— More...
 
struct  AANoReturnFunction
 
struct  AANoReturnCallSite
 NoReturn attribute deduction for a call sites. More...
 
struct  AANoCaptureImpl
 --------------------— Variable Capturing ------------------------------— More...
 
struct  AACaptureUseTracker
 Attributor-aware capture tracker. More...
 
struct  AANoCaptureArgument
 NoCapture attribute for function arguments. More...
 
struct  AANoCaptureCallSiteArgument
 NoCapture attribute for call site arguments. More...
 
struct  AANoCaptureFloating
 NoCapture attribute for floating values. More...
 
struct  AANoCaptureReturned
 NoCapture attribute for function return value. More...
 
struct  AANoCaptureCallSiteReturned
 NoCapture attribute deduction for a call site return value. More...
 
struct  AAValueSimplifyImpl
 
struct  AAValueSimplifyArgument
 
struct  AAValueSimplifyReturned
 
struct  AAValueSimplifyFloating
 
struct  AAValueSimplifyFunction
 
struct  AAValueSimplifyCallSite
 
struct  AAValueSimplifyCallSiteReturned
 
struct  AAValueSimplifyCallSiteArgument
 
struct  AAHeapToStackFunction
 --------------------— Heap-To-Stack Conversion ------------------------— More...
 
struct  AAHeapToStackFunction::AllocationInfo
 
struct  AAHeapToStackFunction::DeallocationInfo
 
struct  AAPrivatizablePtrImpl
 --------------------— Privatizable Pointers ---------------------------— More...
 
struct  AAPrivatizablePtrArgument
 
struct  AAPrivatizablePtrFloating
 
struct  AAPrivatizablePtrCallSiteArgument
 
struct  AAPrivatizablePtrCallSiteReturned
 
struct  AAPrivatizablePtrReturned
 
struct  AAMemoryBehaviorImpl
 -----------------— Memory Behavior Attributes -------------------------— More...
 
struct  AAMemoryBehaviorFloating
 Memory behavior attribute for a floating value. More...
 
struct  AAMemoryBehaviorArgument
 Memory behavior attribute for function argument. More...
 
struct  AAMemoryBehaviorCallSiteArgument
 
struct  AAMemoryBehaviorCallSiteReturned
 Memory behavior attribute for a call site return position. More...
 
struct  AAMemoryBehaviorFunction
 An AA to represent the memory behavior function attributes. More...
 
struct  AAMemoryBehaviorCallSite
 AAMemoryBehavior attribute for call sites. More...
 

Namespaces

 llvm
 ---------------------— PointerInfo ------------------------------------—
 
 llvm::AA
 Abstract Attribute helper functions.
 
 llvm::AA::PointerInfo
 

Macros

#define DEBUG_TYPE   "attributor"
 
#define BUILD_STAT_MSG_IR_ATTR(TYPE, NAME)   ("Number of " #TYPE " marked '" #NAME "'")
 
#define BUILD_STAT_NAME(NAME, TYPE)   NumIR##TYPE##_##NAME
 
#define STATS_DECL_(NAME, MSG)   STATISTIC(NAME, MSG);
 
#define STATS_DECL(NAME, TYPE, MSG)   STATS_DECL_(BUILD_STAT_NAME(NAME, TYPE), MSG);
 
#define STATS_TRACK(NAME, TYPE)   ++(BUILD_STAT_NAME(NAME, TYPE));
 
#define STATS_DECLTRACK(NAME, TYPE, MSG)
 
#define STATS_DECLTRACK_ARG_ATTR(NAME)   STATS_DECLTRACK(NAME, Arguments, BUILD_STAT_MSG_IR_ATTR(arguments, NAME))
 
#define STATS_DECLTRACK_CSARG_ATTR(NAME)
 
#define STATS_DECLTRACK_FN_ATTR(NAME)   STATS_DECLTRACK(NAME, Function, BUILD_STAT_MSG_IR_ATTR(functions, NAME))
 
#define STATS_DECLTRACK_CS_ATTR(NAME)   STATS_DECLTRACK(NAME, CS, BUILD_STAT_MSG_IR_ATTR(call site, NAME))
 
#define STATS_DECLTRACK_FNRET_ATTR(NAME)
 
#define STATS_DECLTRACK_CSRET_ATTR(NAME)
 
#define STATS_DECLTRACK_FLOATING_ATTR(NAME)
 
#define PIPE_OPERATOR(CLASS)
 
#define SWITCH_PK_INV(CLASS, PK, POS_NAME)
 
#define SWITCH_PK_CREATE(CLASS, IRP, PK, SUFFIX)
 
#define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS)
 
#define CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS)
 
#define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS)
 
#define CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS)
 
#define CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS)
 

Functions

 STATISTIC (NumAAs, "Number of abstract attributes created")
 
template<>
ChangeStatus llvm::clampStateAndIndicateChange< DerefState > (DerefState &S, const DerefState &R)
 
static const ValuegetPointerOperand (const Instruction *I, bool AllowVolatile)
 Get pointer operand of memory accessing instruction. More...
 
static ValueconstructPointer (Type *ResTy, Type *PtrElemTy, Value *Ptr, int64_t Offset, IRBuilder< NoFolder > &IRB, const DataLayout &DL)
 Helper function to create a pointer of type ResTy, based on Ptr, and advanced by Offset bytes. More...
 
template<typename StateTy >
static bool genericValueTraversal (Attributor &A, IRPosition IRP, const AbstractAttribute &QueryingAA, StateTy &State, function_ref< bool(Value &, const Instruction *, StateTy &, bool)> VisitValueCB, const Instruction *CtxI, bool UseValueSimplify=true, int MaxValues=16, function_ref< Value *(Value *)> StripCB=nullptr)
 Recursively visit all values that might become IRP at some point. More...
 
const ValuestripAndAccumulateMinimalOffsets (Attributor &A, const AbstractAttribute &QueryingAA, const Value *Val, const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool UseAssumed=false)
 
static const ValuegetMinimalBaseOfAccsesPointerOperand (Attributor &A, const AbstractAttribute &QueryingAA, const Instruction *I, int64_t &BytesOffset, const DataLayout &DL, bool AllowNonInbounds=false)
 
static const ValuegetBasePointerOfAccessPointerOperand (const Instruction *I, int64_t &BytesOffset, const DataLayout &DL, bool AllowNonInbounds=false)
 
template<typename AAType , typename StateType = typename AAType::StateType>
static void clampReturnedValueStates (Attributor &A, const AAType &QueryingAA, StateType &S, const IRPosition::CallBaseContext *CBContext=nullptr)
 Clamp the information known for all returned values of a function (identified by QueryingAA) into S. More...
 
template<typename AAType , typename StateType = typename AAType::StateType>
static void clampCallSiteArgumentStates (Attributor &A, const AAType &QueryingAA, StateType &S)
 Clamp the information known at all call sites for a given argument (identified by QueryingAA) into S. More...
 
template<typename AAType , typename BaseType , typename StateType = typename AAType::StateType>
bool getArgumentStateFromCallBaseContext (Attributor &A, BaseType &QueryingAttribute, IRPosition &Pos, StateType &State)
 This function is the bridge between argument position and the call base context. More...
 
template<class AAType , typename StateType = typename AAType::StateType>
static void followUsesInContext (AAType &AA, Attributor &A, MustBeExecutedContextExplorer &Explorer, const Instruction *CtxI, SetVector< const Use * > &Uses, StateType &State)
 Helper function to accumulate uses. More...
 
template<class AAType , typename StateType = typename AAType::StateType>
static void followUsesInMBEC (AAType &AA, Attributor &A, StateType &S, Instruction &CtxI)
 Use the must-be-executed-context around I to add information into S. More...
 
static int64_t getKnownNonNullAndDerefBytesForUse (Attributor &A, const AbstractAttribute &QueryingAA, Value &AssociatedValue, const Use *U, const Instruction *I, bool &IsNonNull, bool &TrackUse)
 ---------------------— NonNull Argument Attribute ---------------------— More...
 
static bool mayContainUnboundedCycle (Function &F, Attributor &A)
 ---------------------— Will-Return Attributes -------------------------— More...
 
static bool identifyAliveSuccessors (Attributor &A, const CallBase &CB, AbstractAttribute &AA, SmallVectorImpl< const Instruction * > &AliveSuccessors)
 
static bool identifyAliveSuccessors (Attributor &A, const InvokeInst &II, AbstractAttribute &AA, SmallVectorImpl< const Instruction * > &AliveSuccessors)
 
static bool identifyAliveSuccessors (Attributor &A, const BranchInst &BI, AbstractAttribute &AA, SmallVectorImpl< const Instruction * > &AliveSuccessors)
 
static bool identifyAliveSuccessors (Attributor &A, const SwitchInst &SI, AbstractAttribute &AA, SmallVectorImpl< const Instruction * > &AliveSuccessors)
 
static unsigned getKnownAlignForUse (Attributor &A, AAAlign &QueryingAA, Value &AssociatedValue, const Use *U, const Instruction *I, bool &TrackUse)
 

Variables

static cl::opt< bool > ManifestInternal ("attributor-manifest-internal", cl::Hidden, cl::desc("Manifest Attributor internal string attributes."), cl::init(false))
 
static cl::opt< intMaxHeapToStackSize ("max-heap-to-stack-size", cl::init(128), cl::Hidden)
 
static cl::opt< unsigned, trueMaxPotentialValues ("attributor-max-potential-values", cl::Hidden, cl::desc("Maximum number of potential values to be " "tracked for each position."), cl::location(llvm::PotentialConstantIntValuesState::MaxPotentialValues), cl::init(7))
 

Macro Definition Documentation

◆ BUILD_STAT_MSG_IR_ATTR

#define BUILD_STAT_MSG_IR_ATTR (   TYPE,
  NAME 
)    ("Number of " #TYPE " marked '" #NAME "'")

Definition at line 82 of file AttributorAttributes.cpp.

◆ BUILD_STAT_NAME

#define BUILD_STAT_NAME (   NAME,
  TYPE 
)    NumIR##TYPE##_##NAME

Definition at line 84 of file AttributorAttributes.cpp.

◆ CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION

#define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION (   CLASS)
Value:
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
switch (IRP.getPositionKind()) { \
SWITCH_PK_INV(CLASS, IRP_INVALID, "invalid") \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FUNCTION, Function) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE, CallSite) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FLOAT, Floating) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_ARGUMENT, Argument) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_RETURNED, Returned) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_RETURNED, CallSiteReturned) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_ARGUMENT, CallSiteArgument) \
} \
return *AA; \
}

Definition at line 9472 of file AttributorAttributes.cpp.

◆ CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION

#define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION (   CLASS)
Value:
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
switch (IRP.getPositionKind()) { \
SWITCH_PK_INV(CLASS, IRP_INVALID, "invalid") \
SWITCH_PK_INV(CLASS, IRP_FLOAT, "floating") \
SWITCH_PK_INV(CLASS, IRP_ARGUMENT, "argument") \
SWITCH_PK_INV(CLASS, IRP_RETURNED, "returned") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE_RETURNED, "call site returned") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE_ARGUMENT, "call site argument") \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FUNCTION, Function) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE, CallSite) \
} \
return *AA; \
}

Definition at line 9440 of file AttributorAttributes.cpp.

◆ CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION

#define CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION (   CLASS)
Value:
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
switch (IRP.getPositionKind()) { \
SWITCH_PK_INV(CLASS, IRP_INVALID, "invalid") \
SWITCH_PK_INV(CLASS, IRP_ARGUMENT, "argument") \
SWITCH_PK_INV(CLASS, IRP_FLOAT, "floating") \
SWITCH_PK_INV(CLASS, IRP_RETURNED, "returned") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE_RETURNED, "call site returned") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE_ARGUMENT, "call site argument") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE, "call site") \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FUNCTION, Function) \
} \
return *AA; \
}

Definition at line 9488 of file AttributorAttributes.cpp.

◆ CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION

#define CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION (   CLASS)
Value:
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
switch (IRP.getPositionKind()) { \
SWITCH_PK_INV(CLASS, IRP_INVALID, "invalid") \
SWITCH_PK_INV(CLASS, IRP_RETURNED, "returned") \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FUNCTION, Function) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE, CallSite) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FLOAT, Floating) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_ARGUMENT, Argument) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_RETURNED, CallSiteReturned) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_ARGUMENT, CallSiteArgument) \
} \
return *AA; \
}

Definition at line 9504 of file AttributorAttributes.cpp.

◆ CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION

#define CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION (   CLASS)
Value:
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
switch (IRP.getPositionKind()) { \
SWITCH_PK_INV(CLASS, IRP_INVALID, "invalid") \
SWITCH_PK_INV(CLASS, IRP_FUNCTION, "function") \
SWITCH_PK_INV(CLASS, IRP_CALL_SITE, "call site") \
SWITCH_PK_CREATE(CLASS, IRP, IRP_FLOAT, Floating) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_ARGUMENT, Argument) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_RETURNED, Returned) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_RETURNED, CallSiteReturned) \
SWITCH_PK_CREATE(CLASS, IRP, IRP_CALL_SITE_ARGUMENT, CallSiteArgument) \
} \
return *AA; \
}

Definition at line 9456 of file AttributorAttributes.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "attributor"

Definition at line 47 of file AttributorAttributes.cpp.

◆ PIPE_OPERATOR

#define PIPE_OPERATOR (   CLASS)
Value:
raw_ostream &operator<<(raw_ostream &OS, const CLASS &AA) { \
return OS << static_cast<const AbstractAttribute &>(AA); \
}

Definition at line 116 of file AttributorAttributes.cpp.

◆ STATS_DECL

#define STATS_DECL (   NAME,
  TYPE,
  MSG 
)    STATS_DECL_(BUILD_STAT_NAME(NAME, TYPE), MSG);

Definition at line 86 of file AttributorAttributes.cpp.

◆ STATS_DECL_

#define STATS_DECL_ (   NAME,
  MSG 
)    STATISTIC(NAME, MSG);

Definition at line 85 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK

#define STATS_DECLTRACK (   NAME,
  TYPE,
  MSG 
)
Value:
{ \
STATS_DECL(NAME, TYPE, MSG) \
STATS_TRACK(NAME, TYPE) \
}

Definition at line 89 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_ARG_ATTR

#define STATS_DECLTRACK_ARG_ATTR (   NAME)    STATS_DECLTRACK(NAME, Arguments, BUILD_STAT_MSG_IR_ATTR(arguments, NAME))

Definition at line 94 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_CS_ATTR

#define STATS_DECLTRACK_CS_ATTR (   NAME)    STATS_DECLTRACK(NAME, CS, BUILD_STAT_MSG_IR_ATTR(call site, NAME))

Definition at line 101 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_CSARG_ATTR

#define STATS_DECLTRACK_CSARG_ATTR (   NAME)
Value:
STATS_DECLTRACK(NAME, CSArguments, \

Definition at line 96 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_CSRET_ATTR

#define STATS_DECLTRACK_CSRET_ATTR (   NAME)
Value:
STATS_DECLTRACK(NAME, CSReturn, \
BUILD_STAT_MSG_IR_ATTR(call site returns, NAME))

Definition at line 106 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_FLOATING_ATTR

#define STATS_DECLTRACK_FLOATING_ATTR (   NAME)
Value:
STATS_DECLTRACK(NAME, Floating, \
("Number of floating values known to be '" #NAME "'"))

Definition at line 109 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_FN_ATTR

#define STATS_DECLTRACK_FN_ATTR (   NAME)    STATS_DECLTRACK(NAME, Function, BUILD_STAT_MSG_IR_ATTR(functions, NAME))

Definition at line 99 of file AttributorAttributes.cpp.

◆ STATS_DECLTRACK_FNRET_ATTR

#define STATS_DECLTRACK_FNRET_ATTR (   NAME)
Value:
STATS_DECLTRACK(NAME, FunctionReturn, \
BUILD_STAT_MSG_IR_ATTR(function returns, NAME))

Definition at line 103 of file AttributorAttributes.cpp.

◆ STATS_TRACK

#define STATS_TRACK (   NAME,
  TYPE 
)    ++(BUILD_STAT_NAME(NAME, TYPE));

Definition at line 88 of file AttributorAttributes.cpp.

◆ SWITCH_PK_CREATE

#define SWITCH_PK_CREATE (   CLASS,
  IRP,
  PK,
  SUFFIX 
)
Value:
case IRPosition::PK: \
AA = new (A.Allocator) CLASS##SUFFIX(IRP, A); \
++NumAAs; \
break;

Definition at line 9434 of file AttributorAttributes.cpp.

◆ SWITCH_PK_INV

#define SWITCH_PK_INV (   CLASS,
  PK,
  POS_NAME 
)
Value:
case IRPosition::PK: \
llvm_unreachable("Cannot create " #CLASS " for a " POS_NAME " position!");

Definition at line 9430 of file AttributorAttributes.cpp.

Function Documentation

◆ clampCallSiteArgumentStates()

template<typename AAType , typename StateType = typename AAType::StateType>
static void clampCallSiteArgumentStates ( Attributor A,
const AAType &  QueryingAA,
StateType &  S 
)
static

Clamp the information known at all call sites for a given argument (identified by QueryingAA) into S.

Definition at line 527 of file AttributorAttributes.cpp.

References assert(), llvm::IRPosition::callsite_argument(), llvm::dbgs(), llvm::IRPosition::getPositionKind(), llvm::IRPosition::IRP_ARGUMENT, llvm::IRPosition::IRP_INVALID, LLVM_DEBUG, llvm::REQUIRED, S, and T.

◆ clampReturnedValueStates()

template<typename AAType , typename StateType = typename AAType::StateType>
static void clampReturnedValueStates ( Attributor A,
const AAType &  QueryingAA,
StateType &  S,
const IRPosition::CallBaseContext CBContext = nullptr 
)
static

Clamp the information known for all returned values of a function (identified by QueryingAA) into S.

Definition at line 464 of file AttributorAttributes.cpp.

References assert(), llvm::dbgs(), llvm::IRPosition::IRP_CALL_SITE_RETURNED, llvm::IRPosition::IRP_RETURNED, LLVM_DEBUG, llvm::REQUIRED, S, T, and llvm::IRPosition::value().

◆ constructPointer()

static Value* constructPointer ( Type ResTy,
Type PtrElemTy,
Value Ptr,
int64_t  Offset,
IRBuilder< NoFolder > &  IRB,
const DataLayout DL 
)
static

Helper function to create a pointer of type ResTy, based on Ptr, and advanced by Offset bytes.

To aid later analysis the method tries to build getelement pointer instructions that traverse the natural type of Ptr if possible. If that fails, the remaining offset is adjusted byte-wise, hence through a cast to i8*.

TODO: This could probably live somewhere more prominantly if it doesn't already exist.

Definition at line 196 of file AttributorAttributes.cpp.

References assert(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateBitOrPointerCast(), llvm::IRBuilderBase::CreateGEP(), llvm::dbgs(), DL, llvm::errs(), llvm::ConstantInt::get(), llvm::StructLayout::getElementContainingOffset(), llvm::StructLayout::getElementOffset(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::StructLayout::getSizeInBytes(), LLVM_DEBUG, Offset, llvm::StringRef::str(), and llvm::to_string().

Referenced by AAPrivatizablePtrArgument::createInitialization(), and AAPrivatizablePtrArgument::createReplacementValues().

◆ followUsesInContext()

template<class AAType , typename StateType = typename AAType::StateType>
static void followUsesInContext ( AAType &  AA,
Attributor A,
MustBeExecutedContextExplorer Explorer,
const Instruction CtxI,
SetVector< const Use * > &  Uses,
StateType &  State 
)
static

◆ followUsesInMBEC()

template<class AAType , typename StateType = typename AAType::StateType>
static void followUsesInMBEC ( AAType &  AA,
Attributor A,
StateType &  S,
Instruction CtxI 
)
static

Use the must-be-executed-context around I to add information into S.

The AAType class is required to have followUseInMBEC method with the following signature and behaviour:

bool followUseInMBEC(Attributor &A, const Use *U, const Instruction *I) U - Underlying use. I - The user of the U. Returns true if the value should be tracked transitively.

Definition at line 692 of file AttributorAttributes.cpp.

References BB, llvm::MustBeExecutedContextExplorer::checkForAllContext(), followUsesInContext(), I, S, and Uses.

Referenced by AANonNullImpl::initialize(), AADereferenceableImpl::initialize(), and AAAlignImpl::initialize().

◆ genericValueTraversal()

template<typename StateTy >
static bool genericValueTraversal ( Attributor A,
IRPosition  IRP,
const AbstractAttribute QueryingAA,
StateTy State,
function_ref< bool(Value &, const Instruction *, StateTy &, bool)>  VisitValueCB,
const Instruction CtxI,
bool  UseValueSimplify = true,
int  MaxValues = 16,
function_ref< Value *(Value *)>  StripCB = nullptr 
)
static

Recursively visit all values that might become IRP at some point.

This will be done by looking through cast instructions, selects, phis, and calls with the "returned" attribute. Once we cannot look through the value any further, the callback VisitValueCB is invoked and passed the current value, the State, and a flag to indicate if we stripped anything. Stripped means that we unpacked the value associated with IRP at least once. Note that the value used for the callback may still be the value associated with IRP (due to PHIs). To limit how much effort is invested, we will never visit more values than specified by MaxValues.

Definition at line 264 of file AttributorAttributes.cpp.

References Arg, assert(), llvm::numbers::e, llvm::IRPosition::function(), llvm::IRPosition::getAnchorScope(), llvm::IRPosition::getAssociatedValue(), llvm::IRPosition::getCallBaseContext(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Optional< T >::getValue(), llvm::Optional< T >::hasValue(), I, llvm::SmallSet< T, N, C >::insert(), llvm::Type::isPointerTy(), llvm::NONE, llvm::OPTIONAL, llvm::SmallVectorImpl< T >::pop_back_val(), SI, and llvm::Value::stripPointerCasts().

Referenced by llvm::AA::getAssumedUnderlyingObjects().

◆ getArgumentStateFromCallBaseContext()

template<typename AAType , typename BaseType , typename StateType = typename AAType::StateType>
bool getArgumentStateFromCallBaseContext ( Attributor A,
BaseType QueryingAttribute,
IRPosition Pos,
StateType &  State 
)

◆ getBasePointerOfAccessPointerOperand()

static const Value* getBasePointerOfAccessPointerOperand ( const Instruction I,
int64_t &  BytesOffset,
const DataLayout DL,
bool  AllowNonInbounds = false 
)
static

◆ getKnownAlignForUse()

static unsigned getKnownAlignForUse ( Attributor A,
AAAlign QueryingAA,
Value AssociatedValue,
const Use U,
const Instruction I,
bool &  TrackUse 
)
static

◆ getKnownNonNullAndDerefBytesForUse()

static int64_t getKnownNonNullAndDerefBytesForUse ( Attributor A,
const AbstractAttribute QueryingAA,
Value AssociatedValue,
const Use U,
const Instruction I,
bool &  IsNonNull,
bool &  TrackUse 
)
static

◆ getMinimalBaseOfAccsesPointerOperand()

static const Value* getMinimalBaseOfAccsesPointerOperand ( Attributor A,
const AbstractAttribute QueryingAA,
const Instruction I,
int64_t &  BytesOffset,
const DataLayout DL,
bool  AllowNonInbounds = false 
)
static

◆ getPointerOperand()

static const Value* getPointerOperand ( const Instruction I,
bool  AllowVolatile 
)
static

Get pointer operand of memory accessing instruction.

If I is not a memory accessing instruction, return nullptr. If AllowVolatile, is set to false and the instruction is volatile, return nullptr.

Definition at line 164 of file AttributorAttributes.cpp.

References I, and SI.

◆ identifyAliveSuccessors() [1/4]

static bool identifyAliveSuccessors ( Attributor A,
const BranchInst BI,
AbstractAttribute AA,
SmallVectorImpl< const Instruction * > &  AliveSuccessors 
)
static

◆ identifyAliveSuccessors() [2/4]

static bool identifyAliveSuccessors ( Attributor A,
const CallBase CB,
AbstractAttribute AA,
SmallVectorImpl< const Instruction * > &  AliveSuccessors 
)
static

◆ identifyAliveSuccessors() [3/4]

static bool identifyAliveSuccessors ( Attributor A,
const InvokeInst II,
AbstractAttribute AA,
SmallVectorImpl< const Instruction * > &  AliveSuccessors 
)
static

◆ identifyAliveSuccessors() [4/4]

static bool identifyAliveSuccessors ( Attributor A,
const SwitchInst SI,
AbstractAttribute AA,
SmallVectorImpl< const Instruction * > &  AliveSuccessors 
)
static

Definition at line 3794 of file AttributorAttributes.cpp.

References SI, and llvm::successors().

◆ mayContainUnboundedCycle()

static bool mayContainUnboundedCycle ( Function F,
Attributor A 
)
static

---------------------— Will-Return Attributes -------------------------—

Definition at line 2705 of file AttributorAttributes.cpp.

References F, llvm::ScalarEvolution::getSmallConstantMaxTripCount(), llvm::mayContainIrreducibleControl(), and llvm::scc_begin().

Referenced by AAWillReturnFunction::initialize().

◆ STATISTIC()

STATISTIC ( NumAAs  ,
"Number of abstract attributes created"   
)

◆ stripAndAccumulateMinimalOffsets()

const Value* stripAndAccumulateMinimalOffsets ( Attributor A,
const AbstractAttribute QueryingAA,
const Value Val,
const DataLayout DL,
APInt Offset,
bool  AllowNonInbounds,
bool  UseAssumed = false 
)

Variable Documentation

◆ ManifestInternal

cl::opt<bool> ManifestInternal("attributor-manifest-internal", cl::Hidden, cl::desc("Manifest Attributor internal string attributes."), cl::init(false))
static

◆ MaxHeapToStackSize

cl::opt<int> MaxHeapToStackSize("max-heap-to-stack-size", cl::init(128), cl::Hidden)
static

◆ MaxPotentialValues

cl::opt<unsigned, true> MaxPotentialValues("attributor-max-potential-values", cl::Hidden, cl::desc("Maximum number of potential values to be " "tracked for each position."), cl::location(llvm::PotentialConstantIntValuesState::MaxPotentialValues), cl::init(7))
static
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
llvm::Function
Definition: Function.h:61
BUILD_STAT_MSG_IR_ATTR
#define BUILD_STAT_MSG_IR_ATTR(TYPE, NAME)
Definition: AttributorAttributes.cpp:82
llvm::IRPosition::getPositionKind
Kind getPositionKind() const
Return the associated position kind.
Definition: Attributor.h:521
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
call
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
Definition: README.txt:190
llvm::IRPosition
Helper to describe and deal with positions in the LLVM-IR.
Definition: Attributor.h:289
STATS_DECLTRACK
#define STATS_DECLTRACK(NAME, TYPE, MSG)
Definition: AttributorAttributes.cpp:89
A
* A
Definition: README_ALTIVEC.txt:89
llvm::Attributor
The fixpoint analysis framework that orchestrates the attribute deduction.
Definition: Attributor.h:1125
arguments
we compile this esp call L1 $pb L1 esp je LBB1_2 esp ret but is currently always computed in the entry block It would be better to sink the picbase computation down into the block for the as it is the only one that uses it This happens for a lot of code with early outs Another example is loads of arguments
Definition: README.txt:425