Skip to content

Commit 1becd29

Browse files
committed
[NFC] CallGraph related cleanup
Summary: Tidy up some CallGraph-related code in preparation for D82572. Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D82686
1 parent a28d38a commit 1becd29

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

llvm/include/llvm/Analysis/CallGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class CallGraphWrapperPass : public ModulePass {
412412
// graphs by the generic graph algorithms.
413413
//
414414

415-
// Provide graph traits for tranversing call graphs using standard graph
415+
// Provide graph traits for traversing call graphs using standard graph
416416
// traversals.
417417
template <> struct GraphTraits<CallGraphNode *> {
418418
using NodeRef = CallGraphNode *;

llvm/lib/Analysis/CallGraphSCCPass.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,16 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
230230
// If this call site is null, then the function pass deleted the call
231231
// entirely and the WeakTrackingVH nulled it out.
232232
auto *Call = dyn_cast_or_null<CallBase>(I->first);
233-
if (!I->first ||
233+
if (!Call ||
234234
// If we've already seen this call site, then the FunctionPass RAUW'd
235235
// one call with another, which resulted in two "uses" in the edge
236236
// list of the same call.
237-
Calls.count(I->first) ||
237+
Calls.count(Call) ||
238238

239239
// If the call edge is not from a call or invoke, or it is a
240240
// instrinsic call, then the function pass RAUW'd a call with
241241
// another value. This can happen when constant folding happens
242242
// of well known functions etc.
243-
!Call ||
244243
(Call->getCalledFunction() &&
245244
Call->getCalledFunction()->isIntrinsic() &&
246245
Intrinsic::isLeaf(Call->getCalledFunction()->getIntrinsicID()))) {
@@ -267,14 +266,13 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
267266
continue;
268267
}
269268

270-
assert(!Calls.count(I->first) &&
271-
"Call site occurs in node multiple times");
269+
assert(!Calls.count(Call) && "Call site occurs in node multiple times");
272270

273271
if (Call) {
274272
Function *Callee = Call->getCalledFunction();
275273
// Ignore intrinsics because they're not really function calls.
276274
if (!Callee || !(Callee->isIntrinsic()))
277-
Calls.insert(std::make_pair(I->first, I->second));
275+
Calls.insert(std::make_pair(Call, I->second));
278276
}
279277
++I;
280278
}

llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ PreservedAnalyses SyntheticCountsPropagation::run(Module &M,
109109
Optional<Scaled64> Res = None;
110110
if (!Edge.first)
111111
return Res;
112-
assert(isa<Instruction>(Edge.first));
113-
CallBase &CB = cast<CallBase>(*Edge.first);
112+
CallBase &CB = *cast<CallBase>(Edge.first);
114113
Function *Caller = CB.getCaller();
115114
auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(*Caller);
116115

0 commit comments

Comments
 (0)