struct RegisterPass : public RegisterPassBase {
// Register Pass using default constructor...
- RegisterPass(const char *PassArg, const char *Name)
+ RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false)
: RegisterPassBase(Name, PassArg, typeid(PassName),
- callDefaultCtor<PassName>) {}
+ callDefaultCtor<PassName>) {
+ if (CFGOnly) setOnlyUsesCFG();
+ }
// Register Pass using default constructor explicitly...
RegisterPass(const char *PassArg, const char *Name,
- Pass *(*ctor)())
- : RegisterPassBase(Name, PassArg, typeid(PassName), ctor) {}
+ Pass *(*ctor)(), bool CFGOnly = false)
+ : RegisterPassBase(Name, PassArg, typeid(PassName), ctor) {
+ if (CFGOnly) setOnlyUsesCFG();
+ }
// Register Pass using TargetMachine constructor...
RegisterPass(const char *PassArg, const char *Name,
- Pass *(*targetctor)(TargetMachine &))
- : RegisterPassBase(Name, PassArg, typeid(PassName), 0, targetctor) {}
+ Pass *(*targetctor)(TargetMachine &), bool CFGOnly = false)
+ : RegisterPassBase(Name, PassArg, typeid(PassName), 0, targetctor) {
+ if (CFGOnly) setOnlyUsesCFG();
+ }
// Generic constructor version that has an unknown ctor type...
template<typename CtorType>
- RegisterPass(const char *PassArg, const char *Name, CtorType *Fn)
- : RegisterPassBase(Name, PassArg, typeid(PassName), 0) {}
+ RegisterPass(const char *PassArg, const char *Name, CtorType *Fn,
+ bool CFGOnly = false)
+ : RegisterPassBase(Name, PassArg, typeid(PassName), 0) {
+ if (CFGOnly) setOnlyUsesCFG();
+ }
};
/// RegisterOpt - Register something that is to show up in Opt, this is just a
}
};
-/// RegisterAnalysis - Register something that is to show up in Analysis, this
-/// is just a shortcut for specifying RegisterPass... Analyses take a special
-/// argument that, when set to true, tells the system that the analysis ONLY
-/// depends on the shape of the CFG, so if a transformation preserves the CFG
-/// that the analysis is not invalidated.
-///
-template<typename PassName>
-struct RegisterAnalysis : public RegisterPassBase {
- RegisterAnalysis(const char *PassArg, const char *Name,
- bool CFGOnly = false)
- : RegisterPassBase(Name, PassArg, typeid(PassName),
- callDefaultCtor<PassName>) {
- if (CFGOnly) setOnlyUsesCFG();
- }
-};
-
/// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_.
/// Analysis groups are used to define an interface (which need not derive from
}
};
- RegisterAnalysis<CFGPrinter> P1("print-cfg",
- "Print CFG of function to 'dot' file");
+ RegisterPass<CFGPrinter> P1("print-cfg",
+ "Print CFG of function to 'dot' file");
struct CFGOnlyPrinter : public CFGPrinter {
virtual bool runOnFunction(Function &F) {
}
};
- RegisterAnalysis<CFGOnlyPrinter>
+ RegisterPass<CFGOnlyPrinter>
P2("print-cfg-only",
"Print CFG of function to 'dot' file (with no function bodies)");
}
UpdateGlobals("budatastructures-update-from-globals",
cl::desc("Update local graph from global graph when processing function"));
- RegisterAnalysis<BUDataStructures>
+ RegisterPass<BUDataStructures>
X("budatastructure", "Bottom-up Data Structure Analysis");
}
Statistic<> CompleteInd("calltarget", "Number of complete indirect calls");
Statistic<> CompleteEmpty("calltarget", "Number of complete empty calls");
- RegisterAnalysis<CallTargetFinder> X("calltarget", "Find Call Targets (uses DSA)");
+ RegisterPass<CallTargetFinder> X("calltarget","Find Call Targets (uses DSA)");
}
void CallTargetFinder::findIndTargets(Module &M)
using namespace llvm;
namespace {
- RegisterAnalysis<CompleteBUDataStructures>
+ RegisterPass<CompleteBUDataStructures>
X("cbudatastructure", "'Complete' Bottom-up Data Structure Analysis");
Statistic<> NumCBUInlines("cbudatastructures", "Number of graphs inlined");
}
void print(std::ostream &O, const Module* = 0) const { }
};
- static RegisterAnalysis<DSGraphStats> Z("dsstats", "DS Graph Statistics");
+ static RegisterPass<DSGraphStats> Z("dsstats", "DS Graph Statistics");
}
FunctionPass *llvm::createDataStructureStatsPass() {
using namespace llvm;
namespace {
- RegisterAnalysis<EquivClassGraphs> X("eqdatastructure",
+ RegisterPass<EquivClassGraphs> X("eqdatastructure",
"Equivalence-class Bottom-up Data Structure Analysis");
Statistic<> NumEquivBUInlines("equivdatastructures",
"Number of graphs inlined");
void verify(const DSGraph &G);
};
- RegisterAnalysis<DSGC> X("datastructure-gc", "DSA Graph Checking Pass");
+ RegisterPass<DSGC> X("datastructure-gc", "DSA Graph Checking Pass");
}
FunctionPass *llvm::createDataStructureGraphCheckerPass() {
using namespace llvm;
-static RegisterAnalysis<LocalDataStructures>
+static RegisterPass<LocalDataStructures>
X("datastructure", "Local Data Structure Analysis");
static cl::opt<bool>
#endif
namespace {
- RegisterAnalysis<TDDataStructures> // Register the pass
+ RegisterPass<TDDataStructures> // Register the pass
Y("tddatastructure", "Top-down Data Structure Analysis");
Statistic<> NumTDInlines("tddatastructures", "Number of graphs inlined");
#include "llvm/Support/InstIterator.h"
using namespace llvm;
-static RegisterAnalysis<FindUsedTypes>
+static RegisterPass<FindUsedTypes>
X("printusedtypes", "Find Used Types");
// IncorporateType - Incorporate one type and all of its subtypes into the
};
- RegisterAnalysis<InstCount> X("instcount",
- "Counts the various types of Instructions");
+ RegisterPass<InstCount> X("instcount",
+ "Counts the various types of Instructions");
}
FunctionPass *llvm::createInstCountPass() { return new InstCount(); }
#include "llvm/Analysis/IntervalIterator.h"
using namespace llvm;
-static RegisterAnalysis<IntervalPartition>
+static RegisterPass<IntervalPartition>
X("intervals", "Interval Partition Construction", true);
//===----------------------------------------------------------------------===//
#include <iostream>
using namespace llvm;
-static RegisterAnalysis<LoopInfo>
+static RegisterPass<LoopInfo>
X("loops", "Natural Loop Construction", true);
//===----------------------------------------------------------------------===//
// ImmediatePostDominators Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<ImmediatePostDominators>
+static RegisterPass<ImmediatePostDominators>
D("postidom", "Immediate Post-Dominators Construction", true);
unsigned ImmediatePostDominators::DFSPass(BasicBlock *V, InfoRec &VInfo,
// PostDominatorSet Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<PostDominatorSet>
+static RegisterPass<PostDominatorSet>
B("postdomset", "Post-Dominator Set Construction", true);
// Postdominator set construction. This converts the specified function to only
// PostDominatorTree Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<PostDominatorTree>
+static RegisterPass<PostDominatorTree>
F("postdomtree", "Post-Dominator Tree Construction", true);
DominatorTreeBase::Node *PostDominatorTree::getNodeForBlock(BasicBlock *BB) {
// PostETForest Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<PostETForest>
+static RegisterPass<PostETForest>
G("postetforest", "Post-ET-Forest Construction", true);
ETNode *PostETForest::getNodeForBlock(BasicBlock *BB) {
// PostDominanceFrontier Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<PostDominanceFrontier>
+static RegisterPass<PostDominanceFrontier>
H("postdomfrontier", "Post-Dominance Frontier Construction", true);
const DominanceFrontier::DomSetType &
using namespace llvm;
namespace {
- RegisterAnalysis<ScalarEvolution>
+ RegisterPass<ScalarEvolution>
R("scalar-evolution", "Scalar Evolution Analysis");
Statistic<>
using namespace llvm;
namespace {
- RegisterAnalysis<LiveIntervals> X("liveintervals", "Live Interval Analysis");
+ RegisterPass<LiveIntervals> X("liveintervals", "Live Interval Analysis");
static Statistic<> numIntervals
("liveintervals", "Number of original intervals");
#include <iostream>
using namespace llvm;
-static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis");
+static RegisterPass<LiveVariables> X("livevars", "Live Variable Analysis");
void LiveVariables::VarInfo::dump() const {
std::cerr << "Register Defined by: ";
//
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<ImmediateDominators>
+static RegisterPass<ImmediateDominators>
C("idom", "Immediate Dominators Construction", true);
unsigned ImmediateDominators::DFSPass(BasicBlock *V, InfoRec &VInfo,
// DominatorSet Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<DominatorSet>
+static RegisterPass<DominatorSet>
B("domset", "Dominator Set Construction", true);
// dominates - Return true if A dominates B. This performs the special checks
// DominatorTree Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<DominatorTree>
+static RegisterPass<DominatorTree>
E("domtree", "Dominator Tree Construction", true);
// DominatorTreeBase::reset - Free all of the tree node memory.
// DominanceFrontier Implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<DominanceFrontier>
+static RegisterPass<DominanceFrontier>
G("domfrontier", "Dominance Frontier Construction", true);
const DominanceFrontier::DomSetType &
// ETForest implementation
//===----------------------------------------------------------------------===//
-static RegisterAnalysis<ETForest>
+static RegisterPass<ETForest>
D("etforest", "ET Forest Construction", true);
void ETForestBase::reset() {
}
};
- RegisterAnalysis<ExternalFunctionsPassedConstants>
+ RegisterPass<ExternalFunctionsPassedConstants>
P1("externalfnconstants", "Print external fn callsites passed constants");
struct CallGraphPrinter : public ModulePass {
}
};
- RegisterAnalysis<CallGraphPrinter>
+ RegisterPass<CallGraphPrinter>
P2("callgraph", "Print a call graph");
}
}
};
- RegisterAnalysis<CallGraphPrinter> P2("print-callgraph",
- "Print Call Graph to 'dot' file");
+ RegisterPass<CallGraphPrinter> P2("print-callgraph",
+ "Print Call Graph to 'dot' file");
}
}
};
- RegisterAnalysis<CFGSCC>
+ RegisterPass<CFGSCC>
Y("cfgscc", "Print SCCs of each function CFG");
- RegisterAnalysis<CallGraphSCC>
+ RegisterPass<CallGraphSCC>
Z("callscc", "Print SCCs of the Call Graph");
}