Go to the documentation of this file.
22 #define DEBUG_TYPE "code-metrics"
30 const User *U = dyn_cast<User>(V);
35 if (Visited.
insert(Operand).second)
36 if (
const auto *
I = dyn_cast<Instruction>(Operand))
37 if (!
I->mayHaveSideEffects() && !
I->isTerminator())
38 Worklist.push_back(
I);
51 for (
int i = 0;
i < (
int)Worklist.size(); ++
i) {
52 const Value *V = Worklist[
i];
55 "Failed to add a worklist entry to our visited set!");
58 if (!
all_of(V->
users(), [&](
const User *U) { return EphValues.count(U); }))
104 assert(
I->getParent()->getParent() ==
F &&
105 "Found assumption for the wrong function!");
107 if (EphValues.
insert(
I).second)
127 if (
const auto *Call = dyn_cast<CallBase>(&
I)) {
128 if (
const Function *
F = Call->getCalledFunction()) {
135 if (!Call->isNoInline() && IsLoweredToCall &&
136 ((
F->hasInternalLinkage() &&
F->hasOneUse()) || PrepareForLTO)) {
144 if (
F ==
BB->getParent())
152 if (!Call->isInlineAsm())
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()))
InstructionCost NumInsts
Code size cost of the analyzed blocks.
This is an optimization pass for GlobalISel generic memory operations.
Represents a single loop in the control flow graph.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
static void completeEphemeralValues(SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist, SmallPtrSetImpl< const Value * > &EphValues)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
LLVM Basic Block Representation.
bool convergent
True if this function contains a call to a convergent function.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
bool usesDynamicAlloca
True if this function calls alloca (in the C sense).
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 NumBlocks
Number of analyzed blocks.
DenseMap< const BasicBlock *, InstructionCost > NumBBInsts
Keeps track of basic block code size estimates.
bool notDuplicatable
True if this function cannot be duplicated.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void analyzeBasicBlock(const BasicBlock *BB, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &EphValues, bool PrepareForLTO=false)
Add information about a block to the current state.
bool isRecursive
True if this function calls itself.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
A cache of @llvm.assume calls within a function.
unsigned NumCalls
Keep track of the number of calls to 'big' functions.
unsigned NumRets
How many 'ret' instructions the blocks contain.
MutableArrayRef< ResultElem > assumptions()
Access the list of assumption handles currently tracked for this function.
static void appendSpeculatableOperands(const Value *V, SmallPtrSetImpl< const Value * > &Visited, SmallVectorImpl< const Value * > &Worklist)
unsigned NumVectorInsts
How many instructions produce vector values.
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
an instruction to allocate memory on the stack
LLVM Value Representation.
iterator_range< user_iterator > users()
unsigned NumInlineCandidates
The number of calls to internal functions with a single caller.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.