Skip to content

Commit b7d976d

Browse files
[memprof] Use std::move in ContextEdge::ContextEdge (NFC) (#94687)
Since the constructor of ContextEdge takes ContextIds by value, we should move it to the corresponding member variable as suggested by clang-tidy's performance-unnecessary-value-param. While we are at it, this patch updates a couple of callers. To avoid the ambiguity in the evaluation order among the constructor arguments, I'm calling computeAllocType before calling the constructor.
1 parent c007883 commit b7d976d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class CallsiteContextGraph {
402402
ContextEdge(ContextNode *Callee, ContextNode *Caller, uint8_t AllocType,
403403
DenseSet<uint32_t> ContextIds)
404404
: Callee(Callee), Caller(Caller), AllocTypes(AllocType),
405-
ContextIds(ContextIds) {}
405+
ContextIds(std::move(ContextIds)) {}
406406

407407
DenseSet<uint32_t> &getContextIds() { return ContextIds; }
408408

@@ -1127,15 +1127,15 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::connectNewNode(
11271127
continue;
11281128
}
11291129
if (TowardsCallee) {
1130+
uint8_t NewAllocType = computeAllocType(NewEdgeContextIds);
11301131
auto NewEdge = std::make_shared<ContextEdge>(
1131-
Edge->Callee, NewNode, computeAllocType(NewEdgeContextIds),
1132-
NewEdgeContextIds);
1132+
Edge->Callee, NewNode, NewAllocType, std::move(NewEdgeContextIds));
11331133
NewNode->CalleeEdges.push_back(NewEdge);
11341134
NewEdge->Callee->CallerEdges.push_back(NewEdge);
11351135
} else {
1136+
uint8_t NewAllocType = computeAllocType(NewEdgeContextIds);
11361137
auto NewEdge = std::make_shared<ContextEdge>(
1137-
NewNode, Edge->Caller, computeAllocType(NewEdgeContextIds),
1138-
NewEdgeContextIds);
1138+
NewNode, Edge->Caller, NewAllocType, std::move(NewEdgeContextIds));
11391139
NewNode->CallerEdges.push_back(NewEdge);
11401140
NewEdge->Caller->CalleeEdges.push_back(NewEdge);
11411141
}

0 commit comments

Comments
 (0)