Lines Matching defs:Edge
321 for (auto &Edge : *Edges)
322 Count += Edge->getContextIds().size();
324 for (auto &Edge : *Edges)
325 ContextIds.insert(Edge->getContextIds().begin(),
326 Edge->getContextIds().end());
339 for (auto &Edge : *Edges) {
340 AllocType |= Edge->AllocTypes;
354 for (auto &Edge : *Edges) {
355 if (!Edge->getContextIds().empty())
394 void eraseCalleeEdge(const ContextEdge *Edge);
395 void eraseCallerEdge(const ContextEdge *Edge);
420 /// Edge in the Callsite Context Graph from a ContextNode N to a caller or
466 friend raw_ostream &operator<<(raw_ostream &OS, const ContextEdge &Edge) {
467 Edge.print(OS);
547 void removeEdgeFromGraph(ContextEdge *Edge, EdgeIter *EI = nullptr,
693 /// Create a clone of Edge's callee and move Edge to that new callee node,
695 /// If ContextIdsToMove is non-empty, only that subset of Edge's ids are
698 moveEdgeToNewCalleeClone(const std::shared_ptr<ContextEdge> &Edge,
701 /// Change the callee of Edge to existing callee clone NewCallee, performing
703 /// If ContextIdsToMove is non-empty, only that subset of Edge's ids are
705 void moveEdgeToExistingCalleeClone(const std::shared_ptr<ContextEdge> &Edge,
715 void moveCalleeEdgeToNewCaller(const std::shared_ptr<ContextEdge> &Edge,
1043 for (auto &Edge : CallerEdges) {
1044 if (Edge->Caller == Caller) {
1045 Edge->AllocTypes |= (uint8_t)AllocType;
1046 Edge->getContextIds().insert(ContextId);
1050 std::shared_ptr<ContextEdge> Edge = std::make_shared<ContextEdge>(
1052 CallerEdges.push_back(Edge);
1053 Caller->CalleeEdges.push_back(Edge);
1058 ContextEdge *Edge, EdgeIter *EI, bool CalleeIter) {
1059 assert(!EI || (*EI)->get() == Edge);
1060 // Save the Caller and Callee pointers so we can erase Edge from their edge
1061 // lists after clearing Edge below. We do the clearing first in case it is
1063 // shared_ptr references to Edge).
1064 auto *Callee = Edge->Callee;
1065 auto *Caller = Edge->Caller;
1068 // removed edges if Edge is not destructed because there is still a shared_ptr
1070 Edge->clear();
1073 Callee->eraseCallerEdge(Edge);
1074 Caller->eraseCalleeEdge(Edge);
1076 Callee->eraseCallerEdge(Edge);
1079 Caller->eraseCalleeEdge(Edge);
1088 auto Edge = *EI;
1089 if (Edge->AllocTypes == (uint8_t)AllocationType::None) {
1090 assert(Edge->ContextIds.empty());
1091 removeEdgeFromGraph(Edge.get(), &EI, /*CalleeIter=*/true);
1101 auto Edge = *EI;
1102 if (Edge->AllocTypes == (uint8_t)AllocationType::None) {
1103 assert(Edge->ContextIds.empty());
1104 Edge->Caller->eraseCalleeEdge(Edge.get());
1115 for (const auto &Edge : CalleeEdges)
1116 if (Edge->Callee == Callee)
1117 return Edge.get();
1125 for (const auto &Edge : CallerEdges)
1126 if (Edge->Caller == Caller)
1127 return Edge.get();
1133 eraseCalleeEdge(const ContextEdge *Edge) {
1135 CalleeEdges, [Edge](const std::shared_ptr<ContextEdge> &CalleeEdge) {
1136 return CalleeEdge.get() == Edge;
1144 eraseCallerEdge(const ContextEdge *Edge) {
1146 CallerEdges, [Edge](const std::shared_ptr<ContextEdge> &CallerEdge) {
1147 return CallerEdge.get() == Edge;
1310 for (const auto &Edge : Node->CallerEdges) {
1311 auto Inserted = Visited.insert(Edge.get());
1314 ContextNode *NextNode = Edge->Caller;
1315 DenseSet<uint32_t> NewIdsToAdd = GetNewIds(Edge->getContextIds());
1319 Edge->getContextIds().insert(NewIdsToAdd.begin(), NewIdsToAdd.end());
1342 auto Edge = *EI;
1343 // Remove any matching context ids from Edge, return set that were found and
1347 set_subtract(Edge->getContextIds(), RemainingContextIds, NewEdgeContextIds,
1358 Edge->Callee, NewNode, NewAllocType, std::move(NewEdgeContextIds));
1364 NewNode, Edge->Caller, NewAllocType, std::move(NewEdgeContextIds));
1369 if (Edge->getContextIds().empty()) {
1370 removeEdgeFromGraph(Edge.get(), &EI, TowardsCallee);
1379 const std::shared_ptr<ContextEdge<DerivedCCG, FuncTy, CallTy>> &Edge) {
1382 assert(Edge->AllocTypes != (uint8_t)AllocationType::None);
1383 assert(!Edge->ContextIds.empty());
1400 for (const auto &Edge : llvm::drop_begin(Node->CallerEdges)) {
1402 checkEdge<DerivedCCG, FuncTy, CallTy>(Edge);
1403 set_union(CallerEdgeContextIds, Edge->ContextIds);
1416 for (const auto &Edge : llvm::drop_begin(Node->CalleeEdges)) {
1418 checkEdge<DerivedCCG, FuncTy, CallTy>(Edge);
1419 set_union(CalleeEdgeContextIds, Edge->getContextIds());
1451 for (auto &Edge : CallerEdges) {
1453 if (Edge->isRemoved()) {
1454 assert(!is_contained(Node->CallerEdges, Edge));
1457 assignStackNodesPostOrder(Edge->Caller, Visited, StackIdToMatchingCalls,
1555 auto *Edge = CurNode->findEdgeFromCaller(PrevNode);
1556 if (!Edge) {
1564 set_intersect(SavedContextIds, Edge->getContextIds());
1760 auto *Edge = CurNode->findEdgeFromCaller(PrevNode);
1770 if (!Edge) {
1778 set_intersect(StackSequenceContextIds, Edge->getContextIds());
2193 auto Edge = *EI;
2194 if (!Edge->Callee->hasCall())
2196 assert(NodeToCallingFunc.count(Edge->Callee));
2286 for (const auto &Edge : Node->CalleeEdges) {
2287 if (!Edge->Callee->hasCall())
2289 const FuncTy *ProfiledCalleeFunc = NodeToCallingFunc[Edge->Callee];
2291 CalleeNodeToCallInfo[Edge->Callee] =
2318 for (auto &Edge : CalleeEdges) {
2319 if (!Edge->Callee->hasCall())
2328 if (!CalleeNodeToCallInfo.contains(Edge->Callee)) {
2336 auto *Info = CalleeNodeToCallInfo[Edge->Callee];
2366 moveCalleeEdgeToNewCaller(Edge, CallerNodeToUse);
2397 auto Edge = *EI;
2398 const FuncTy *ProfiledCalleeFunc = NodeToCallingFunc[Edge->Callee];
2399 const FuncTy *CallerFunc = NodeToCallingFunc[Edge->Caller];
2411 auto AddEdge = [Edge, &EI](ContextNode *Caller, ContextNode *Callee) {
2416 CurEdge->ContextIds.insert(Edge->ContextIds.begin(),
2417 Edge->ContextIds.end());
2418 CurEdge->AllocTypes |= Edge->AllocTypes;
2424 Callee, Caller, Edge->AllocTypes, Edge->ContextIds);
2426 if (Caller == Edge->Caller) {
2432 assert(*EI == Edge &&
2440 auto *CurCalleeNode = Edge->Callee;
2446 NewNode->AllocTypes |= Edge->AllocTypes;
2452 NewNode->AllocTypes = Edge->AllocTypes;
2462 AddEdge(Edge->Caller, CurCalleeNode);
2465 // Save this because Edge's fields get cleared below when removed.
2466 auto *Caller = Edge->Caller;
2470 removeEdgeFromGraph(Edge.get(), &EI, /*CalleeIter=*/true);
2474 // to Edge->Caller, or found an existing one. Either way we are guaranteed
2800 for (auto &Edge : CalleeEdges)
2801 OS << "\t\t" << *Edge << "\n";
2803 for (auto &Edge : CallerEdges)
2804 OS << "\t\t" << *Edge << "\n";
2826 OS << "Edge from Callee " << Callee << " to Caller: " << Caller
2892 for (auto &Edge : Node->CallerEdges)
2893 checkEdge<DerivedCCG, FuncTy, CallTy>(Edge);
2989 auto &Edge = *(ChildIter.getCurrent());
2990 return (Twine("tooltip=\"") + getContextIds(Edge->ContextIds) + "\"" +
2991 Twine(",fillcolor=\"") + getColor(Edge->AllocTypes) + "\"")
3046 const std::shared_ptr<ContextEdge> &Edge,
3048 ContextNode *Node = Edge->Callee;
3054 moveEdgeToExistingCalleeClone(Edge, Clone, /*NewClone=*/true,
3061 moveEdgeToExistingCalleeClone(const std::shared_ptr<ContextEdge> &Edge,
3064 // NewCallee and Edge's current callee must be clones of the same original
3065 // node (Edge's current callee may be the original node too).
3066 assert(NewCallee->getOrigNode() == Edge->Callee->getOrigNode());
3068 ContextNode *OldCallee = Edge->Callee;
3072 auto ExistingEdgeToNewCallee = NewCallee->findEdgeFromCaller(Edge->Caller);
3075 // edge. Copy in Edge's ids for simplicity.
3077 ContextIdsToMove = Edge->getContextIds();
3079 // If we are moving all of Edge's ids, then just move the whole Edge.
3081 if (Edge->getContextIds().size() == ContextIdsToMove.size()) {
3082 // First, update the alloc types on New Callee from Edge.
3083 // Do this before we potentially clear Edge's fields below!
3084 NewCallee->AllocTypes |= Edge->AllocTypes;
3085 // Moving the whole Edge.
3088 // onto it, and remove the existing Edge.
3091 ExistingEdgeToNewCallee->AllocTypes |= Edge->AllocTypes;
3092 assert(Edge->ContextIds == ContextIdsToMove);
3093 removeEdgeFromGraph(Edge.get());
3095 // Otherwise just reconnect Edge to NewCallee.
3096 Edge->Callee = NewCallee;
3097 NewCallee->CallerEdges.push_back(Edge);
3099 OldCallee->eraseCallerEdge(Edge.get());
3100 // Don't need to update Edge's context ids since we are simply
3104 // Only moving a subset of Edge's ids.
3116 NewCallee, Edge->Caller, CallerEdgeAllocType, ContextIdsToMove);
3117 Edge->Caller->CalleeEdges.push_back(NewEdge);
3121 // those ids and update the alloc type on the original Edge.
3123 set_subtract(Edge->ContextIds, ContextIdsToMove);
3124 Edge->AllocTypes = computeAllocType(Edge->ContextIds);
3126 // Now walk the old callee node's callee edges and move Edge's context ids
3177 moveCalleeEdgeToNewCaller(const std::shared_ptr<ContextEdge> &Edge,
3180 ContextNode *OldCaller = Edge->Caller;
3181 OldCaller->eraseCalleeEdge(Edge.get());
3185 auto ExistingEdgeToNewCaller = NewCaller->findEdgeFromCallee(Edge->Callee);
3189 // onto it, and remove the existing Edge.
3191 Edge->getContextIds().begin(), Edge->getContextIds().end());
3192 ExistingEdgeToNewCaller->AllocTypes |= Edge->AllocTypes;
3193 Edge->ContextIds.clear();
3194 Edge->AllocTypes = (uint8_t)AllocationType::None;
3195 Edge->Callee->eraseCallerEdge(Edge.get());
3197 // Otherwise just reconnect Edge to NewCaller.
3198 Edge->Caller = NewCaller;
3199 NewCaller->CalleeEdges.push_back(Edge);
3200 // Don't need to update Edge's context ids since we are simply
3204 NewCaller->AllocTypes |= Edge->AllocTypes;
3206 // Now walk the old caller node's caller edges and move Edge's context ids
3217 set_intersection(OldCallerEdge->getContextIds(), Edge->getContextIds());
3274 for (auto &Edge : CallerEdges) {
3276 if (Edge->isRemoved()) {
3277 assert(!is_contained(Node->CallerEdges, Edge));
3280 recursivelyRemoveNoneTypeCalleeEdges(Edge->Caller, Visited);
3335 for (auto &Edge : CallerEdges) {
3337 if (Edge->isRemoved()) {
3338 assert(!is_contained(Node->CallerEdges, Edge));
3342 if (!Visited.count(Edge->Caller) && !Edge->Caller->CloneOf) {
3343 identifyClones(Edge->Caller, Visited, AllocContextIds);
3788 const std::shared_ptr<ContextEdge> &Edge = *EI;
3790 CallsiteToCalleeFuncCloneMap[Edge->Caller];
3941 for (auto &Edge : CloneCallerEdges) {
3943 if (!Edge->Caller->hasCall())
3947 if (CallsiteToCalleeFuncCloneMap.count(Edge->Caller)) {
3949 CallsiteToCalleeFuncCloneMap[Edge->Caller];
3955 // been assigned to the same function clone called by Edge's caller
3956 // - if Edge's caller calls another callsite within Node's original
3989 moveEdgeToExistingCalleeClone(Edge, NewClone);
3994 ContextNode *NewClone = moveEdgeToNewCalleeClone(Edge);
4051 RecordCalleeFuncOfCallsite(Edge->Caller,
4086 for (auto &Edge : Node->CallerEdges)
4087 UpdateCalls(Edge->Caller, Visited, UpdateCalls);