forked from OSchip/llvm-project
[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
This commit is contained in:
parent
a28d38a6bc
commit
1becd298b8
|
@ -412,7 +412,7 @@ public:
|
||||||
// graphs by the generic graph algorithms.
|
// graphs by the generic graph algorithms.
|
||||||
//
|
//
|
||||||
|
|
||||||
// Provide graph traits for tranversing call graphs using standard graph
|
// Provide graph traits for traversing call graphs using standard graph
|
||||||
// traversals.
|
// traversals.
|
||||||
template <> struct GraphTraits<CallGraphNode *> {
|
template <> struct GraphTraits<CallGraphNode *> {
|
||||||
using NodeRef = CallGraphNode *;
|
using NodeRef = CallGraphNode *;
|
||||||
|
|
|
@ -230,17 +230,16 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
|
||||||
// If this call site is null, then the function pass deleted the call
|
// If this call site is null, then the function pass deleted the call
|
||||||
// entirely and the WeakTrackingVH nulled it out.
|
// entirely and the WeakTrackingVH nulled it out.
|
||||||
auto *Call = dyn_cast_or_null<CallBase>(I->first);
|
auto *Call = dyn_cast_or_null<CallBase>(I->first);
|
||||||
if (!I->first ||
|
if (!Call ||
|
||||||
// If we've already seen this call site, then the FunctionPass RAUW'd
|
// If we've already seen this call site, then the FunctionPass RAUW'd
|
||||||
// one call with another, which resulted in two "uses" in the edge
|
// one call with another, which resulted in two "uses" in the edge
|
||||||
// list of the same call.
|
// list of the same call.
|
||||||
Calls.count(I->first) ||
|
Calls.count(Call) ||
|
||||||
|
|
||||||
// If the call edge is not from a call or invoke, or it is a
|
// If the call edge is not from a call or invoke, or it is a
|
||||||
// instrinsic call, then the function pass RAUW'd a call with
|
// instrinsic call, then the function pass RAUW'd a call with
|
||||||
// another value. This can happen when constant folding happens
|
// another value. This can happen when constant folding happens
|
||||||
// of well known functions etc.
|
// of well known functions etc.
|
||||||
!Call ||
|
|
||||||
(Call->getCalledFunction() &&
|
(Call->getCalledFunction() &&
|
||||||
Call->getCalledFunction()->isIntrinsic() &&
|
Call->getCalledFunction()->isIntrinsic() &&
|
||||||
Intrinsic::isLeaf(Call->getCalledFunction()->getIntrinsicID()))) {
|
Intrinsic::isLeaf(Call->getCalledFunction()->getIntrinsicID()))) {
|
||||||
|
@ -267,14 +266,13 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!Calls.count(I->first) &&
|
assert(!Calls.count(Call) && "Call site occurs in node multiple times");
|
||||||
"Call site occurs in node multiple times");
|
|
||||||
|
|
||||||
if (Call) {
|
if (Call) {
|
||||||
Function *Callee = Call->getCalledFunction();
|
Function *Callee = Call->getCalledFunction();
|
||||||
// Ignore intrinsics because they're not really function calls.
|
// Ignore intrinsics because they're not really function calls.
|
||||||
if (!Callee || !(Callee->isIntrinsic()))
|
if (!Callee || !(Callee->isIntrinsic()))
|
||||||
Calls.insert(std::make_pair(I->first, I->second));
|
Calls.insert(std::make_pair(Call, I->second));
|
||||||
}
|
}
|
||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,7 @@ PreservedAnalyses SyntheticCountsPropagation::run(Module &M,
|
||||||
Optional<Scaled64> Res = None;
|
Optional<Scaled64> Res = None;
|
||||||
if (!Edge.first)
|
if (!Edge.first)
|
||||||
return Res;
|
return Res;
|
||||||
assert(isa<Instruction>(Edge.first));
|
CallBase &CB = *cast<CallBase>(Edge.first);
|
||||||
CallBase &CB = cast<CallBase>(*Edge.first);
|
|
||||||
Function *Caller = CB.getCaller();
|
Function *Caller = CB.getCaller();
|
||||||
auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(*Caller);
|
auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(*Caller);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue