summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/CallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2019-04-19 05:59:42 +0000
committerChandler Carruth <chandlerc@gmail.com>2019-04-19 05:59:42 +0000
commitce3f75df1fffdb8bcef66ff82e83fa895e00260e (patch)
treec18d789929358501b909110e07e9a0df414b6717 /llvm/lib/Analysis/CallGraph.cpp
parent82216048e6bcdf2e37b356e45954ac8cdceaab50 (diff)
downloadbcm5719-llvm-ce3f75df1fffdb8bcef66ff82e83fa895e00260e.tar.gz
bcm5719-llvm-ce3f75df1fffdb8bcef66ff82e83fa895e00260e.zip
[CallSite removal] Move the legacy PM, call graph, and some inliner
code to `CallBase`. This patch focuses on the legacy PM, call graph, and some of inliner and legacy passes interacting with those APIs from `CallSite` to the new `CallBase` class. No interesting changes. Differential Revision: https://reviews.llvm.org/D60412 llvm-svn: 358739
Diffstat (limited to 'llvm/lib/Analysis/CallGraph.cpp')
-rw-r--r--llvm/lib/Analysis/CallGraph.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp
index e4e9e71adbd..ec5e94d499b 100644
--- a/llvm/lib/Analysis/CallGraph.cpp
+++ b/llvm/lib/Analysis/CallGraph.cpp
@@ -10,7 +10,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Config/llvm-config.h"
-#include "llvm/IR/CallSite.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Intrinsics.h"
@@ -63,25 +62,25 @@ void CallGraph::addToCallGraph(Function *F) {
// If this function has external linkage or has its address taken, anything
// could call it.
if (!F->hasLocalLinkage() || F->hasAddressTaken())
- ExternalCallingNode->addCalledFunction(CallSite(), Node);
+ ExternalCallingNode->addCalledFunction(nullptr, Node);
// If this function is not defined in this translation unit, it could call
// anything.
if (F->isDeclaration() && !F->isIntrinsic())
- Node->addCalledFunction(CallSite(), CallsExternalNode.get());
+ Node->addCalledFunction(nullptr, CallsExternalNode.get());
// Look for calls by this function.
for (BasicBlock &BB : *F)
for (Instruction &I : BB) {
- if (auto CS = CallSite(&I)) {
- const Function *Callee = CS.getCalledFunction();
+ if (auto *Call = dyn_cast<CallBase>(&I)) {
+ const Function *Callee = Call->getCalledFunction();
if (!Callee || !Intrinsic::isLeaf(Callee->getIntrinsicID()))
// Indirect calls of intrinsics are not allowed so no need to check.
// We can be more precise here by using TargetArg returned by
// Intrinsic::isLeaf.
- Node->addCalledFunction(CS, CallsExternalNode.get());
+ Node->addCalledFunction(Call, CallsExternalNode.get());
else if (!Callee->isIntrinsic())
- Node->addCalledFunction(CS, getOrInsertFunction(Callee));
+ Node->addCalledFunction(Call, getOrInsertFunction(Callee));
}
}
}
@@ -184,10 +183,10 @@ LLVM_DUMP_METHOD void CallGraphNode::dump() const { print(dbgs()); }
/// removeCallEdgeFor - This method removes the edge in the node for the
/// specified call site. Note that this method takes linear time, so it
/// should be used sparingly.
-void CallGraphNode::removeCallEdgeFor(CallSite CS) {
+void CallGraphNode::removeCallEdgeFor(CallBase &Call) {
for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) {
assert(I != CalledFunctions.end() && "Cannot find callsite to remove!");
- if (I->first == CS.getInstruction()) {
+ if (I->first == &Call) {
I->second->DropRef();
*I = CalledFunctions.back();
CalledFunctions.pop_back();
@@ -227,13 +226,13 @@ void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee) {
/// replaceCallEdge - This method replaces the edge in the node for the
/// specified call site with a new one. Note that this method takes linear
/// time, so it should be used sparingly.
-void CallGraphNode::replaceCallEdge(CallSite CS,
- CallSite NewCS, CallGraphNode *NewNode){
+void CallGraphNode::replaceCallEdge(CallBase &Call, CallBase &NewCall,
+ CallGraphNode *NewNode) {
for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) {
assert(I != CalledFunctions.end() && "Cannot find callsite to remove!");
- if (I->first == CS.getInstruction()) {
+ if (I->first == &Call) {
I->second->DropRef();
- I->first = NewCS.getInstruction();
+ I->first = &NewCall;
I->second = NewNode;
NewNode->AddRef();
return;
OpenPOWER on IntegriCloud