26 #define DEBUG_TYPE "code-metrics"
40 while (!WorkSet.
empty()) {
44 if (!Visited.
insert(V).second)
48 bool FoundNEUse =
false;
59 DEBUG(
dbgs() <<
"Ephemeral Value: " << *V <<
"\n");
61 if (
const User *U = dyn_cast<User>(V))
62 for (
const Value *J : U->operands()) {
102 "Found assumption for the wrong function!");
115 unsigned NumInstsBeforeThisBB =
NumInsts;
119 if (EphValues.
count(II))
123 if (isa<CallInst>(II) || isa<InvokeInst>(II)) {
130 if (!CS.
isNoInline() &&
F->hasInternalLinkage() &&
F->hasOneUse())
150 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
151 if (!AI->isStaticAlloca())
155 if (isa<ExtractElementInst>(II) || II->getType()->isVectorTy())
158 if (
const CallInst *CI = dyn_cast<CallInst>(II))
159 if (CI->cannotDuplicate())
162 if (
const InvokeInst *InvI = dyn_cast<InvokeInst>(II))
163 if (InvI->cannotDuplicate())
void push_back(const T &Elt)
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.
CallInst - 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.
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...
iterator begin()
Instruction iterator methods.
unsigned NumBlocks
Number of analyzed blocks.
bool usesDynamicAlloca
True if this function calls alloca (in the C sense).
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
void analyzeBasicBlock(const BasicBlock *BB, const TargetTransformInfo &TTI, SmallPtrSetImpl< const Value * > &EphValues)
Add information about a block to the current state.
LLVM Basic Block Representation.
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
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
contains - 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 fuction.
iterator erase(iterator I)
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...
bool isNoInline() const
Return true if the call should not be inlined.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
iterator_range< user_iterator > users()
static void completeEphemeralValues(SmallVector< const Value *, 16 > &WorkSet, SmallPtrSetImpl< const Value * > &EphValues)
ImmutableCallSite - establish a view to a call site for examination.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
unsigned NumRets
How many 'ret' instructions the blocks contain.
LLVM Value Representation.
InvokeInst - Invoke instruction.
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
isSafeToSpeculativelyExecute - Return true if the instruction does not have any effects besides calcu...
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
AllocaInst - an instruction to allocate memory on the stack.