23#define DEBUG_TYPE "code-metrics"
35 for (
const Value *Operand : U->operands())
36 if (Visited.
insert(Operand).second)
38 if (!
I->mayHaveSideEffects() && !
I->isTerminator())
52 for (
int i = 0; i < (int)Worklist.
size(); ++i) {
53 const Value *V = Worklist[i];
56 "Failed to add a worklist entry to our visited set!");
59 if (!
all_of(V->users(), [&](
const User *U) { return EphValues.count(U); }))
85 if (!L->contains(
I->getParent()))
105 assert(
I->getParent()->getParent() ==
F &&
106 "Found assumption for the wrong function!");
108 if (EphValues.
insert(
I).second)
120 for (
const auto *U :
I.users()) {
142 bool IsLoweredToCall =
TTI.isLoweredToCall(
F);
148 if (!
Call->isNoInline() && IsLoweredToCall &&
149 ((
F->hasInternalLinkage() &&
F->hasOneLiveUse()) ||
160 }
else if (!
Call->isInlineAsm()) {
163 if (PrepareForLTO && !
Call->isNoInline())
169 if (!AI->isStaticAlloca())
177 I.isUsedOutsideOfBlock(BB)) {
179 <<
"\n Cannot duplicate a token value used outside "
180 "the current block (except convergence control).\n");
185 if (CB->cannotDuplicate())
193 CB->getConvergenceControlToken()) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool extendsConvergenceOutsideLoop(const Instruction &I, const Loop *L)
static void appendSpeculatableOperands(const Value *V, SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist)
static void completeEphemeralValues(SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist, SmallPtrSetImpl< const Value * > &EphValues)
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
This file defines the SmallPtrSet class.
an instruction to allocate memory on the stack
A cache of @llvm.assume calls within a function.
MutableArrayRef< WeakVH > assumptions()
Access the list of assumption handles currently tracked for this function.
LLVM Basic Block Representation.
unsigned getNumber() const
const Function * getParent() const
Return the enclosing method, or null if none.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
unsigned getMaxBlockNumber() const
Return a value larger than the largest block number.
Represents a single loop in the control flow graph.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool usesDynamicAlloca
True if this function calls alloca (in the C sense).
ConvergenceKind Convergence
The kind of convergence specified in this function.
bool notDuplicatable
True if this function cannot be duplicated.
SmallVector< InstructionCost, 0 > NumBBInsts
Keeps track of basic block code size estimates. Indexed by block number.
unsigned NumInlineCandidates
The number of calls to internal functions with a single caller.
bool isRecursive
True if this function calls itself.
static LLVM_ABI void collectEphemeralValues(const Loop *L, AssumptionCache *AC, SmallPtrSetImpl< const Value * > &EphValues)
Collect a loop's ephemeral values (those used only by an assume or similar intrinsics in the loop).
unsigned NumRets
How many 'ret' instructions the blocks contain.
LLVM_ABI void analyzeBasicBlock(const BasicBlock *BB, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &EphValues, bool PrepareForLTO=false, const Loop *L=nullptr)
Add information about a block to the current state.
unsigned NumVectorInsts
How many instructions produce vector values.
InstructionCost NumInsts
Code size cost of the analyzed blocks.