#include "llvm/Module.h"
#include "Support/STLExtras.h"
#include "Support/TypeInfo.h"
-#include <stdio.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <sys/unistd.h>
+#include "Config/stdio.h"
+#include "Config/sys/resource.h"
+#include "Config/sys/time.h"
+#include "Config/unistd.h"
#include <set>
// IncludeFile - Stub function used to help linking out.
// AnalysisUsage Class Implementation
//
-// preservesCFG - This function should be called to by the pass, iff they do
+// setPreservesCFG - This function should be called to by the pass, iff they do
// not:
//
// 1. Add or remove basic blocks from the function
// This function annotates the AnalysisUsage info object to say that analyses
// that only depend on the CFG are preserved by this pass.
//
-void AnalysisUsage::preservesCFG() {
+void AnalysisUsage::setPreservesCFG() {
// Since this transformation doesn't modify the CFG, it preserves all analyses
// that only depend on the CFG (like dominators, loop info, etc...)
//
void PassManager::add(Pass *P) { PM->add(P); }
bool PassManager::run(Module &M) { return PM->run(M); }
+//===----------------------------------------------------------------------===//
+// FunctionPassManager implementation - The FunctionPassManager class
+// is a simple Pimpl class that wraps the PassManagerT template. It
+// is like PassManager, but only deals in FunctionPasses.
+//
+FunctionPassManager::FunctionPassManager() : PM(new PassManagerT<Function>()) {}
+FunctionPassManager::~FunctionPassManager() { delete PM; }
+void FunctionPassManager::add(FunctionPass *P) { PM->add(P); }
+void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); }
+bool FunctionPassManager::run(Function &F) { return PM->run(F); }
+
//===----------------------------------------------------------------------===//
// TimingInfo Class - This class is used to calculate information about the
EnableTiming("time-passes",
cl::desc("Time each pass, printing elapsed time for each on exit"));
-// Create method. If Timing is enabled, this creates and returns a new timing
-// object, otherwise it returns null.
-//
-TimingInfo *TimingInfo::create() {
- return EnableTiming ? new TimingInfo() : 0;
+// createTheTimeInfo - This method either initializes the TheTimeInfo pointer to
+// a non null value (if the -time-passes option is enabled) or it leaves it
+// null. It may be called multiple times.
+void TimingInfo::createTheTimeInfo() {
+ if (!EnableTiming || TheTimeInfo) return;
+
+ // Constructed the first time this is called, iff -time-passes is enabled.
+ // This guarantees that the object will be constructed before static globals,
+ // thus it will be destroyed before them.
+ static TimingInfo TTI;
+ TheTimeInfo = &TTI;
}
void PMDebug::PrintArgumentInformation(const Pass *P) {
PM->addPass(this, AU);
}
+bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
+ return Resolver->getAnalysisToUpdate(AnalysisID) != 0;
+}
+
// dumpPassStructure - Implement the -debug-passes=Structure option
void Pass::dumpPassStructure(unsigned Offset) {
std::cerr << std::string(Offset*2, ' ') << getPassName() << "\n";
}
// print - Print out the internal state of the pass. This is called by Analyse
-// to print out the contents of an analysis. Otherwise it is not neccesary to
+// to print out the contents of an analysis. Otherwise it is not necessary to
// implement this method.
//
void Pass::print(std::ostream &O) const {