Lines Matching +full:per +full:- +full:context
1 //===-- MemoryProfileInfo.cpp - memory profile info ------------------------==//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
19 #define DEBUG_TYPE "memory-profile-info"
21 // Upper bound on lifetime access density (accesses per byte per lifetime sec)
24 "memprof-lifetime-access-density-cold-threshold", cl::init(0.05),
26 cl::desc("The threshold the lifetime access density (accesses per byte per "
30 // per byte per sec above). This is to avoid pessimizing short lived objects.
32 "memprof-ave-lifetime-cold-threshold", cl::init(200), cl::Hidden,
39 "memprof-min-ave-lifetime-access-density-hot-threshold", cl::init(1000),
45 "memprof-report-hinted-sizes", cl::init(false), cl::Hidden,
81 assert(MIB->getNumOperands() >= 2); in getMIBStackNode()
83 return cast<MDNode>(MIB->getOperand(0)); in getMIBStackNode()
87 assert(MIB->getNumOperands() >= 2); in getMIBAllocType()
91 auto *MDS = dyn_cast<MDString>(MIB->getOperand(1)); in getMIBAllocType()
93 if (MDS->getString() == "cold") { in getMIBAllocType()
95 } else if (MDS->getString() == "hot") { in getMIBAllocType()
102 if (MIB->getNumOperands() < 3) in getMIBTotalSize()
104 return mdconst::dyn_extract<ConstantInt>(MIB->getOperand(2))->getZExtValue(); in getMIBTotalSize()
128 CI->addFnAttr(A); in addAllocTypeAttribute()
148 Alloc->AllocTypes |= static_cast<uint8_t>(AllocType); in addCallStack()
149 Alloc->TotalSize += TotalSize; in addCallStack()
158 auto Next = Curr->Callers.find(StackId); in addCallStack()
159 if (Next != Curr->Callers.end()) { in addCallStack()
160 Curr = Next->second; in addCallStack()
161 Curr->AllocTypes |= static_cast<uint8_t>(AllocType); in addCallStack()
162 Curr->TotalSize += TotalSize; in addCallStack()
167 Curr->Callers[StackId] = New; in addCallStack()
177 CallStack.reserve(StackMD->getNumOperands()); in addCallStack()
178 for (const auto &MIBStackIter : StackMD->operands()) { in addCallStack()
181 CallStack.push_back(StackId->getZExtValue()); in addCallStack()
206 // Trim context below the first node in a prefix with a single alloc type. in buildMIBNodes()
208 if (hasSingleAllocType(Node->AllocTypes)) { in buildMIBNodes()
210 Ctx, MIBCallStack, (AllocationType)Node->AllocTypes, Node->TotalSize)); in buildMIBNodes()
216 if (!Node->Callers.empty()) { in buildMIBNodes()
217 bool NodeHasAmbiguousCallerContext = Node->Callers.size() > 1; in buildMIBNodes()
219 for (auto &Caller : Node->Callers) { in buildMIBNodes()
230 // the context in this case (see below). in buildMIBNodes()
240 // trim the context just below the deepest context split, which is this in buildMIBNodes()
241 // node if the callee has an ambiguous caller context (multiple callers), in buildMIBNodes()
243 // non-cold allocation type. in buildMIBNodes()
247 Node->TotalSize)); in buildMIBNodes()
255 auto &Ctx = CI->getContext(); in buildAndAttachMIBMetadata()
256 if (hasSingleAllocType(Alloc->AllocTypes)) { in buildAndAttachMIBMetadata()
257 addAllocTypeAttribute(Ctx, CI, (AllocationType)Alloc->AllocTypes); in buildAndAttachMIBMetadata()
259 assert(Alloc->TotalSize); in buildAndAttachMIBMetadata()
262 << getAllocTypeAttributeString((AllocationType)Alloc->AllocTypes) in buildAndAttachMIBMetadata()
263 << ": " << Alloc->TotalSize << "\n"; in buildAndAttachMIBMetadata()
270 assert(!Alloc->Callers.empty() && "addCallStack has not been called yet"); in buildAndAttachMIBMetadata()
277 CI->setMetadata(LLVMContext::MD_memprof, MDNode::get(Ctx, MIBNodes)); in buildAndAttachMIBMetadata()
282 // it non-cold allocation type. in buildAndAttachMIBMetadata()
294 Iter = End ? N->op_end() : N->op_begin(); in CallStackIterator()
300 assert(Iter != N->op_end()); in operator *()
303 return StackIdCInt->getZExtValue(); in operator *()
308 return mdconst::dyn_extract<ConstantInt>(N->operands().back()) in back()
309 ->getZExtValue(); in back()