LLVM
15.0.0git
|
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SetVector.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/InstructionSimplify.h"
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Assumptions.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalValue.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/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO/ArgumentPromotion.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <cassert>
Go to the source code of this file.
Classes | |
struct | llvm::DenseMapInfo< AAPointerInfo::Access > |
Helper for AA::PointerInfo::Acccess DenseMap/Set usage. More... | |
struct | llvm::DenseMapInfo< AAPointerInfo ::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 | AA::PointerInfo::State |
A type to track pointer/struct usage and accesses for AAPointerInfo. More... | |
struct | AA::PointerInfo::State::Accesses |
We store accesses in a set with the instruction as key. More... | |
Namespaces | |
llvm | |
This is an optimization pass for GlobalISel generic memory operations. | |
llvm::AA | |
Abstract Attribute helper functions. | |
llvm::AA::PointerInfo | |
Functions | |
STATISTIC (NumAAs, "Number of abstract attributes created") | |
template<> | |
ChangeStatus | llvm::clampStateAndIndicateChange< DerefState > (DerefState &S, const DerefState &R) |
static const Value * | getPointerOperand (const Instruction *I, bool AllowVolatile) |
Get pointer operand of memory accessing instruction. More... | |
static Value * | constructPointer (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 &UsedAssumedInformation, bool UseValueSimplify=true, int MaxValues=16, function_ref< Value *(Value *)> StripCB=nullptr, AA::ValueScope VS=AA::Interprocedural) |
Recursively visit all values that might become IRP at some point. More... | |
static const Value * | stripAndAccumulateOffsets (Attributor &A, const AbstractAttribute &QueryingAA, const Value *Val, const DataLayout &DL, APInt &Offset, bool GetMinOffset, bool AllowNonInbounds, bool UseAssumed=false) |
static const Value * | getMinimalBaseOfPointer (Attributor &A, const AbstractAttribute &QueryingAA, const Value *Ptr, 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... | |
Variables | |
static cl::opt< bool > | ManifestInternal ("attributor-manifest-internal", cl::Hidden, cl::desc("Manifest Attributor internal string attributes."), cl::init(false)) |
static cl::opt< int > | MaxHeapToStackSize ("max-heap-to-stack-size", cl::init(128), cl::Hidden) |
static 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 cl::opt< unsigned > | MaxInterferingAccesses ("attributor-max-interfering-accesses", cl::Hidden, cl::desc("Maximum number of interfering accesses to " "check before assuming all might interfere."), cl::init(6)) |
#define BUILD_STAT_MSG_IR_ATTR | ( | TYPE, | |
NAME | |||
) | ("Number of " #TYPE " marked '" #NAME "'") |
Definition at line 102 of file AttributorAttributes.cpp.
#define BUILD_STAT_NAME | ( | NAME, | |
TYPE | |||
) | NumIR##TYPE##_##NAME |
Definition at line 104 of file AttributorAttributes.cpp.
#define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 10296 of file AttributorAttributes.cpp.
#define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 10264 of file AttributorAttributes.cpp.
#define CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 10312 of file AttributorAttributes.cpp.
#define CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 10328 of file AttributorAttributes.cpp.
#define CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 10280 of file AttributorAttributes.cpp.
#define DEBUG_TYPE "attributor" |
Definition at line 61 of file AttributorAttributes.cpp.
#define PIPE_OPERATOR | ( | CLASS | ) |
Definition at line 136 of file AttributorAttributes.cpp.
#define STATS_DECL | ( | NAME, | |
TYPE, | |||
MSG | |||
) | STATS_DECL_(BUILD_STAT_NAME(NAME, TYPE), MSG); |
Definition at line 106 of file AttributorAttributes.cpp.
#define STATS_DECL_ | ( | NAME, | |
MSG | |||
) | STATISTIC(NAME, MSG); |
Definition at line 105 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK | ( | NAME, | |
TYPE, | |||
MSG | |||
) |
Definition at line 109 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_ARG_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Arguments, BUILD_STAT_MSG_IR_ATTR(arguments, NAME)) |
Definition at line 114 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_CS_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, CS, BUILD_STAT_MSG_IR_ATTR(call site, NAME)) |
Definition at line 121 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_CSARG_ATTR | ( | NAME | ) |
Definition at line 116 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_CSRET_ATTR | ( | NAME | ) |
Definition at line 126 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_FLOATING_ATTR | ( | NAME | ) |
Definition at line 129 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_FN_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Function, BUILD_STAT_MSG_IR_ATTR(functions, NAME)) |
Definition at line 119 of file AttributorAttributes.cpp.
#define STATS_DECLTRACK_FNRET_ATTR | ( | NAME | ) |
Definition at line 123 of file AttributorAttributes.cpp.
#define STATS_TRACK | ( | NAME, | |
TYPE | |||
) | ++(BUILD_STAT_NAME(NAME, TYPE)); |
Definition at line 108 of file AttributorAttributes.cpp.
#define SWITCH_PK_CREATE | ( | CLASS, | |
IRP, | |||
PK, | |||
SUFFIX | |||
) |
Definition at line 10258 of file AttributorAttributes.cpp.
#define SWITCH_PK_INV | ( | CLASS, | |
PK, | |||
POS_NAME | |||
) |
Definition at line 10254 of file AttributorAttributes.cpp.
|
static |
Clamp the information known for all returned values of a function (identified by QueryingAA
) into S
.
Definition at line 529 of file AttributorAttributes.cpp.
References A, assert(), llvm::dbgs(), LLVM_DEBUG, S, and T.
|
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 218 of file AttributorAttributes.cpp.
References assert(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateGEP(), llvm::IRBuilderBase::CreatePointerBitCastOrAddrSpaceCast(), llvm::dbgs(), DL, llvm::IRBuilderBase::getInt(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::Value::getName(), llvm::Value::getType(), llvm::APInt::getZExtValue(), LLVM_DEBUG, llvm::StringRef::str(), and llvm::to_string().
|
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
. If VS
does not contain the Interprocedural bit, only values valid in the scope of CtxI
will be visited and simplification into other scopes is prevented.
Definition at line 269 of file AttributorAttributes.cpp.
References llvm::all_of(), llvm::SmallVectorImpl< T >::append(), Arg, llvm::dbgs(), llvm::numbers::e, F, llvm::IRPosition::function(), llvm::IRPosition::getAssociatedValue(), llvm::Instruction::getFunction(), llvm::BasicBlock::getParent(), llvm::AA::getPotentiallyLoadedValues(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Optional< T >::getValue(), llvm::Optional< T >::hasValue(), I, llvm::SmallSet< T, N, C >::insert(), llvm::AA::Interprocedural, llvm::AA::isDynamicallyUnique(), llvm::Type::isPointerTy(), llvm::AA::isValidInScope(), LLVM_DEBUG, llvm::NONE, llvm::SmallVectorImpl< T >::pop_back_val(), SI, llvm::Value::stripPointerCasts(), and llvm::AArch64CC::VS.
Referenced by llvm::AA::getAssumedUnderlyingObjects().
|
static |
Definition at line 514 of file AttributorAttributes.cpp.
References A, llvm::sampleprof::Base, DL, llvm::APInt::getSExtValue(), llvm::Value::getType(), and stripAndAccumulateOffsets().
|
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 186 of file AttributorAttributes.cpp.
STATISTIC | ( | NumAAs | , |
"Number of abstract attributes created" | |||
) |
|
static |
Definition at line 482 of file AttributorAttributes.cpp.
References A, DL, llvm::IntegerRangeState::getAssumed(), llvm::IntegerRangeState::getKnown(), llvm::ConstantRange::getSignedMin(), llvm::CSKYAttrs::NONE, Offset, and llvm::Value::stripAndAccumulateConstantOffsets().
Referenced by getMinimalBaseOfPointer().
|
static |
|
static |