26 #define DEBUG_TYPE "code-metrics"
39 if (Visited.
insert(Operand).second)
54 for (
int i = 0;
i < (int)Worklist.
size(); ++
i) {
55 const Value *V = Worklist[
i];
58 "Failed to add a worklist entry to our visited set!");
65 DEBUG(
dbgs() <<
"Ephemeral Value: " << *V <<
"\n");
90 if (EphValues.
insert(I).second)
108 "Found assumption for the wrong function!");
110 if (EphValues.
insert(I).second)
123 unsigned NumInstsBeforeThisBB =
NumInsts;
130 if (isa<CallInst>(
I) || isa<InvokeInst>(
I)) {
137 if (!CS.
isNoInline() &&
F->hasInternalLinkage() &&
F->hasOneUse())
144 if (
F == BB->getParent())
157 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(&
I)) {
158 if (!AI->isStaticAlloca())
162 if (isa<ExtractElementInst>(
I) ||
I.getType()->isVectorTy())
165 if (
I.getType()->isTokenTy() &&
I.isUsedOutsideOfBlock(BB))
168 if (
const CallInst *CI = dyn_cast<CallInst>(&
I)) {
169 if (CI->cannotDuplicate())
171 if (CI->isConvergent())
175 if (
const InvokeInst *InvI = dyn_cast<InvokeInst>(&
I))
176 if (InvI->cannotDuplicate())
182 if (isa<ReturnInst>(BB->getTerminator()))
void push_back(const T &Elt)
static void completeEphemeralValues(SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist, SmallPtrSetImpl< const Value * > &EphValues)
bool convergent
True if this function contains a call to a convergent function.
bool isRecursive
True if this function calls itself.
unsigned NumVectorInsts
How many instructions produce vector values.
unsigned NumCalls
Keep track of the number of calls to 'big' functions.
This class represents a function call, abstracting a target machine's calling convention.
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
A cache of .assume calls within a function.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned NumInlineCandidates
The number of calls to internal functions with a single caller.
bool notDuplicatable
True if this function cannot be duplicated.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
unsigned NumBlocks
Number of analyzed blocks.
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
bool usesDynamicAlloca
True if this function calls alloca (in the C sense).
LLVM Basic Block Representation.
bool isNoInline() const
Return true if the call should not be inlined.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
MutableArrayRef< WeakVH > assumptions()
Access the list of assumption handles currently tracked for this function.
DenseMap< const BasicBlock *, unsigned > NumBBInsts
Keeps track of basic block code size estimates.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
iterator_range< user_iterator > users()
Represents a single loop in the control flow graph.
ImmutableCallSite - establish a view to a call site for examination.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
unsigned NumRets
How many 'ret' instructions the blocks contain.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static void appendSpeculatableOperands(const Value *V, SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist)
void analyzeBasicBlock(const BasicBlock *BB, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &EphValues)
Add information about a block to the current state.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
LLVM Value Representation.
static 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 NumInsts
Number of instructions in the analyzed blocks.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack