aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CallGraphSCCPass.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
commit044eb2f6afba375a914ac9d8024f8f5142bb912e (patch)
tree1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/Analysis/CallGraphSCCPass.cpp
parenteb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff)
downloadsrc-044eb2f6afba375a914ac9d8024f8f5142bb912e.tar.gz
src-044eb2f6afba375a914ac9d8024f8f5142bb912e.zip
Vendor import of llvm trunk r321017:vendor/llvm/llvm-trunk-r321017
Notes
Notes: svn path=/vendor/llvm/dist/; revision=326938 svn path=/vendor/llvm/llvm-trunk-r321017/; revision=326939; tag=vendor/llvm/llvm-trunk-r321017
Diffstat (limited to 'lib/Analysis/CallGraphSCCPass.cpp')
-rw-r--r--lib/Analysis/CallGraphSCCPass.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/lib/Analysis/CallGraphSCCPass.cpp b/lib/Analysis/CallGraphSCCPass.cpp
index facda246936d..a2dda58a6a2f 100644
--- a/lib/Analysis/CallGraphSCCPass.cpp
+++ b/lib/Analysis/CallGraphSCCPass.cpp
@@ -16,18 +16,27 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/CallGraphSCCPass.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CallGraph.h"
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/Function.h"
-#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManagers.h"
+#include "llvm/IR/Module.h"
#include "llvm/IR/OptBisect.h"
+#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <string>
+#include <utility>
+#include <vector>
+
using namespace llvm;
#define DEBUG_TYPE "cgscc-passmgr"
@@ -47,8 +56,8 @@ namespace {
class CGPassManager : public ModulePass, public PMDataManager {
public:
static char ID;
- explicit CGPassManager()
- : ModulePass(ID), PMDataManager() { }
+
+ explicit CGPassManager() : ModulePass(ID), PMDataManager() {}
/// Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the module, and if so, return true.
@@ -106,7 +115,6 @@ private:
char CGPassManager::ID = 0;
-
bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
CallGraph &CG, bool &CallGraphUpToDate,
bool &DevirtualizedCall) {
@@ -135,7 +143,6 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
return Changed;
}
-
assert(PM->getPassManagerType() == PMT_FunctionPassManager &&
"Invalid CGPassManager member");
FPPassManager *FPP = (FPPassManager*)P;
@@ -162,7 +169,6 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
return Changed;
}
-
/// Scan the functions in the specified CFG and resync the
/// callgraph with the call sites found in it. This is used after
/// FunctionPasses have potentially munged the callgraph, and can be used after
@@ -172,7 +178,6 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
/// meaning it turned an indirect call into a direct call. This happens when
/// a function pass like GVN optimizes away stuff feeding the indirect call.
/// This never happens in checking mode.
-///
bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
bool CheckingMode) {
DenseMap<Value*, CallGraphNode*> CallSites;
@@ -484,7 +489,6 @@ bool CGPassManager::runOnModule(Module &M) {
return Changed;
}
-
/// Initialize CG
bool CGPassManager::doInitialization(CallGraph &CG) {
bool Changed = false;
@@ -536,7 +540,6 @@ void CallGraphSCC::ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
CGI->ReplaceNode(Old, New);
}
-
//===----------------------------------------------------------------------===//
// CallGraphSCCPass Implementation
//===----------------------------------------------------------------------===//
@@ -586,22 +589,23 @@ void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<CallGraphWrapperPass>();
}
-
//===----------------------------------------------------------------------===//
// PrintCallGraphPass Implementation
//===----------------------------------------------------------------------===//
namespace {
+
/// PrintCallGraphPass - Print a Module corresponding to a call graph.
///
class PrintCallGraphPass : public CallGraphSCCPass {
std::string Banner;
- raw_ostream &Out; // raw_ostream to print on.
+ raw_ostream &OS; // raw_ostream to print on.
public:
static char ID;
- PrintCallGraphPass(const std::string &B, raw_ostream &o)
- : CallGraphSCCPass(ID), Banner(B), Out(o) {}
+
+ PrintCallGraphPass(const std::string &B, raw_ostream &OS)
+ : CallGraphSCCPass(ID), Banner(B), OS(OS) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
@@ -612,18 +616,18 @@ namespace {
auto PrintBannerOnce = [&] () {
if (BannerPrinted)
return;
- Out << Banner;
+ OS << Banner;
BannerPrinted = true;
};
for (CallGraphNode *CGN : SCC) {
if (Function *F = CGN->getFunction()) {
if (!F->isDeclaration() && isFunctionInPrintList(F->getName())) {
PrintBannerOnce();
- F->print(Out);
+ F->print(OS);
}
- } else if (llvm::isFunctionInPrintList("*")) {
+ } else if (isFunctionInPrintList("*")) {
PrintBannerOnce();
- Out << "\nPrinting <null> Function\n";
+ OS << "\nPrinting <null> Function\n";
}
}
return false;
@@ -636,9 +640,9 @@ namespace {
char PrintCallGraphPass::ID = 0;
-Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O,
+Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &OS,
const std::string &Banner) const {
- return new PrintCallGraphPass(Banner, O);
+ return new PrintCallGraphPass(Banner, OS);
}
bool CallGraphSCCPass::skipSCC(CallGraphSCC &SCC) const {
@@ -649,5 +653,6 @@ bool CallGraphSCCPass::skipSCC(CallGraphSCC &SCC) const {
}
char DummyCGSCCPass::ID = 0;
+
INITIALIZE_PASS(DummyCGSCCPass, "DummyCGSCCPass", "DummyCGSCCPass", false,
false)