diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2019-04-19 05:59:42 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2019-04-19 05:59:42 +0000 |
commit | ce3f75df1fffdb8bcef66ff82e83fa895e00260e (patch) | |
tree | c18d789929358501b909110e07e9a0df414b6717 /llvm/lib/Transforms | |
parent | 82216048e6bcdf2e37b356e45954ac8cdceaab50 (diff) | |
download | bcm5719-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/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Coroutines/Coroutines.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/Inliner.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/PruneEH.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 14 |
5 files changed, 19 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp index 7bd87fd29a6..a581d1d2116 100644 --- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -176,15 +176,15 @@ static void buildCGN(CallGraph &CG, CallGraphNode *Node) { // Look for calls by this function. for (Instruction &I : instructions(F)) - if (CallSite CS = CallSite(cast<Value>(&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, CG.getCallsExternalNode()); + Node->addCalledFunction(Call, CG.getCallsExternalNode()); else if (!Callee->isIntrinsic()) - Node->addCalledFunction(CS, CG.getOrInsertFunction(Callee)); + Node->addCalledFunction(Call, CG.getOrInsertFunction(Callee)); } } diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index dbbe03d1dac..5f994625f19 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -1104,7 +1104,9 @@ bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) { CallGraphNode *NewCalleeNode = CG.getOrInsertFunction(NewCS.getCalledFunction()); CallGraphNode *CallerNode = CG[Caller]; - CallerNode->replaceCallEdge(OldCS, NewCS, NewCalleeNode); + CallerNode->replaceCallEdge(*cast<CallBase>(OldCS.getInstruction()), + *cast<CallBase>(NewCS.getInstruction()), + NewCalleeNode); }; const TargetTransformInfo &TTI = diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp index 4047c0acd19..f6e8b5344f5 100644 --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -671,7 +671,7 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, LLVM_DEBUG(dbgs() << " -> Deleting dead call: " << *Instr << "\n"); // Update the call graph by deleting the edge from Callee to Caller. setInlineRemark(CS, "trivially dead"); - CG[Caller]->removeCallEdgeFor(CS); + CG[Caller]->removeCallEdgeFor(*cast<CallBase>(CS.getInstruction())); Instr->eraseFromParent(); ++NumCallsDeleted; } else { diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index ef7b43e8b55..cb3915dfb67 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -242,12 +242,12 @@ static void DeleteBasicBlock(BasicBlock *BB, CallGraph &CG) { break; } - 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())) - CGN->removeCallEdgeFor(CS); + CGN->removeCallEdgeFor(*Call); else if (!Callee->isIntrinsic()) - CGN->removeCallEdgeFor(CS); + CGN->removeCallEdgeFor(*Call); } if (!I->use_empty()) diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 7443a7f9c5e..a29fbc81c4c 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1215,14 +1215,14 @@ static void UpdateCallGraphAfterInlining(CallSite CS, // If the call was inlined, but then constant folded, there is no edge to // add. Check for this case. - Instruction *NewCall = dyn_cast<Instruction>(VMI->second); + auto *NewCall = dyn_cast<CallBase>(VMI->second); if (!NewCall) continue; // We do not treat intrinsic calls like real function calls because we // expect them to become inline code; do not add an edge for an intrinsic. - CallSite CS = CallSite(NewCall); - if (CS && CS.getCalledFunction() && CS.getCalledFunction()->isIntrinsic()) + if (NewCall->getCalledFunction() && + NewCall->getCalledFunction()->isIntrinsic()) continue; // Remember that this call site got inlined for the client of @@ -1235,19 +1235,19 @@ static void UpdateCallGraphAfterInlining(CallSite CS, // destination. This can also happen if the call graph node of the caller // was just unnecessarily imprecise. if (!I->second->getFunction()) - if (Function *F = CallSite(NewCall).getCalledFunction()) { + if (Function *F = NewCall->getCalledFunction()) { // Indirect call site resolved to direct call. - CallerNode->addCalledFunction(CallSite(NewCall), CG[F]); + CallerNode->addCalledFunction(NewCall, CG[F]); continue; } - CallerNode->addCalledFunction(CallSite(NewCall), I->second); + CallerNode->addCalledFunction(NewCall, I->second); } // Update the call graph by deleting the edge from Callee to Caller. We must // do this after the loop above in case Caller and Callee are the same. - CallerNode->removeCallEdgeFor(CS); + CallerNode->removeCallEdgeFor(*cast<CallBase>(CS.getInstruction())); } static void HandleByValArgumentInit(Value *Dst, Value *Src, Module *M, |