#include "llvm/Support/Timer.h"
#include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Mutex.h"
clEnumValEnd));
} // End of llvm namespace
+/// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
+/// or higher is specified.
+bool PMDataManager::isPassDebuggingExecutionsOrMore() const {
+ return PassDebugging >= Executions;
+}
+
+
+
+
void PassManagerPrettyStackEntry::print(raw_ostream &OS) const {
if (V == 0 && M == 0)
OS << "Releasing pass '";
// Print passes managed by this manager
void dumpPassStructure(unsigned Offset) {
- llvm::cerr << std::string(Offset*2, ' ') << "BasicBlockPass Manager\n";
+ llvm::errs() << std::string(Offset*2, ' ') << "BasicBlockPass Manager\n";
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
BasicBlockPass *BP = getContainedPass(Index);
BP->dumpPassStructure(Offset + 1);
// Print passes managed by this manager
void dumpPassStructure(unsigned Offset) {
- llvm::cerr << std::string(Offset*2, ' ') << "ModulePass Manager\n";
+ llvm::errs() << std::string(Offset*2, ' ') << "ModulePass Manager\n";
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
ModulePass *MP = getContainedPass(Index);
MP->dumpPassStructure(Offset + 1);
if (PassDebugging < Arguments)
return;
- cerr << "Pass Arguments: ";
+ errs() << "Pass Arguments: ";
for (SmallVector<PMDataManager *, 8>::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
(*I)->dumpPassArguments();
- cerr << "\n";
+ errs() << "\n";
}
void PMTopLevelManager::initializeAllAnalysisInfo() {
DominatorTree OtherDT;
OtherDT.getBase().recalculate(F);
if (DT->compare(OtherDT)) {
- cerr << "Dominator Information for " << F.getNameStart() << "\n";
- cerr << "Pass '" << P.getPassName() << "'\n";
- cerr << "----- Valid -----\n";
+ errs() << "Dominator Information for " << F.getName() << "\n";
+ errs() << "Pass '" << P.getPassName() << "'\n";
+ errs() << "----- Valid -----\n";
OtherDT.dump();
- cerr << "----- Invalid -----\n";
+ errs() << "----- Invalid -----\n";
DT->dump();
- assert(0 && "Invalid dominator info");
+ llvm_unreachable("Invalid dominator info");
}
DominanceFrontier *DF = P.getAnalysisIfAvailable<DominanceFrontier>();
std::vector<BasicBlock*> DTRoots = DT->getRoots();
OtherDF.calculate(*DT, DT->getNode(DTRoots[0]));
if (DF->compare(OtherDF)) {
- cerr << "Dominator Information for " << F.getNameStart() << "\n";
- cerr << "Pass '" << P.getPassName() << "'\n";
- cerr << "----- Valid -----\n";
+ errs() << "Dominator Information for " << F.getName() << "\n";
+ errs() << "Pass '" << P.getPassName() << "'\n";
+ errs() << "----- Valid -----\n";
OtherDF.dump();
- cerr << "----- Invalid -----\n";
+ errs() << "----- Invalid -----\n";
DF->dump();
- assert(0 && "Invalid dominator info");
+ llvm_unreachable("Invalid dominator info");
}
}
// Remove this analysis
if (PassDebugging >= Details) {
Pass *S = Info->second;
- cerr << " -- '" << P->getPassName() << "' is not preserving '";
- cerr << S->getPassName() << "'\n";
+ errs() << " -- '" << P->getPassName() << "' is not preserving '";
+ errs() << S->getPassName() << "'\n";
}
AvailableAnalysis.erase(Info);
}
}
/// Remove analysis passes that are not used any longer
-void PMDataManager::removeDeadPasses(Pass *P, const char *Msg,
+void PMDataManager::removeDeadPasses(Pass *P, const StringRef &Msg,
enum PassDebuggingString DBG_STR) {
SmallVector<Pass *, 12> DeadPasses;
TPM->collectLastUses(DeadPasses, P);
if (PassDebugging >= Details && !DeadPasses.empty()) {
- cerr << " -*- '" << P->getPassName();
- cerr << "' is the last user of following pass instances.";
- cerr << " Free these instances\n";
+ errs() << " -*- '" << P->getPassName();
+ errs() << "' is the last user of following pass instances.";
+ errs() << " Free these instances\n";
}
for (SmallVector<Pass *, 12>::iterator I = DeadPasses.begin(),
// Keep track of higher level analysis used by this manager.
HigherLevelAnalysis.push_back(PRequired);
} else
- assert(0 && "Unable to accomodate Required Pass");
+ llvm_unreachable("Unable to accomodate Required Pass");
}
// Set P as P's last user until someone starts using P.
for (SmallVector<Pass *, 12>::iterator I = LUses.begin(),
E = LUses.end(); I != E; ++I) {
- llvm::cerr << "--" << std::string(Offset*2, ' ');
+ llvm::errs() << "--" << std::string(Offset*2, ' ');
(*I)->dumpPassStructure(0);
}
}
else
if (const PassInfo *PI = (*I)->getPassInfo())
if (!PI->isAnalysisGroup())
- cerr << " -" << PI->getPassArgument();
+ errs() << " -" << PI->getPassArgument();
}
}
void PMDataManager::dumpPassInfo(Pass *P, enum PassDebuggingString S1,
enum PassDebuggingString S2,
- const char *Msg) {
+ const StringRef &Msg) {
if (PassDebugging < Executions)
return;
- cerr << (void*)this << std::string(getDepth()*2+1, ' ');
+ errs() << (void*)this << std::string(getDepth()*2+1, ' ');
switch (S1) {
case EXECUTION_MSG:
- cerr << "Executing Pass '" << P->getPassName();
+ errs() << "Executing Pass '" << P->getPassName();
break;
case MODIFICATION_MSG:
- cerr << "Made Modification '" << P->getPassName();
+ errs() << "Made Modification '" << P->getPassName();
break;
case FREEING_MSG:
- cerr << " Freeing Pass '" << P->getPassName();
+ errs() << " Freeing Pass '" << P->getPassName();
break;
default:
break;
}
switch (S2) {
case ON_BASICBLOCK_MSG:
- cerr << "' on BasicBlock '" << Msg << "'...\n";
+ errs() << "' on BasicBlock '" << Msg << "'...\n";
break;
case ON_FUNCTION_MSG:
- cerr << "' on Function '" << Msg << "'...\n";
+ errs() << "' on Function '" << Msg << "'...\n";
break;
case ON_MODULE_MSG:
- cerr << "' on Module '" << Msg << "'...\n";
+ errs() << "' on Module '" << Msg << "'...\n";
break;
case ON_LOOP_MSG:
- cerr << "' on Loop " << Msg << "'...\n";
+ errs() << "' on Loop '" << Msg << "'...\n";
break;
case ON_CG_MSG:
- cerr << "' on Call Graph " << Msg << "'...\n";
+ errs() << "' on Call Graph Nodes '" << Msg << "'...\n";
break;
default:
break;
dumpAnalysisUsage("Preserved", P, analysisUsage.getPreservedSet());
}
-void PMDataManager::dumpAnalysisUsage(const char *Msg, const Pass *P,
+void PMDataManager::dumpAnalysisUsage(const StringRef &Msg, const Pass *P,
const AnalysisUsage::VectorType &Set) const {
assert(PassDebugging >= Details);
if (Set.empty())
return;
- cerr << (void*)P << std::string(getDepth()*2+3, ' ') << Msg << " Analyses:";
+ errs() << (void*)P << std::string(getDepth()*2+3, ' ') << Msg << " Analyses:";
for (unsigned i = 0; i != Set.size(); ++i) {
- if (i) cerr << ",";
- cerr << " " << Set[i]->getPassName();
+ if (i) errs() << ',';
+ errs() << ' ' << Set[i]->getPassName();
}
- cerr << "\n";
+ errs() << '\n';
}
/// Add RequiredPass into list of lower level passes required by pass P.
// checks whether any lower level manager will be able to provide this
// analysis info on demand or not.
#ifndef NDEBUG
- cerr << "Unable to schedule '" << RequiredPass->getPassName();
- cerr << "' required by '" << P->getPassName() << "'\n";
+ errs() << "Unable to schedule '" << RequiredPass->getPassName();
+ errs() << "' required by '" << P->getPassName() << "'\n";
#endif
- assert(0 && "Unable to schedule pass");
+ llvm_unreachable("Unable to schedule pass");
}
// Destructor
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
BasicBlockPass *BP = getContainedPass(Index);
- dumpPassInfo(BP, EXECUTION_MSG, ON_BASICBLOCK_MSG, I->getNameStart());
+ dumpPassInfo(BP, EXECUTION_MSG, ON_BASICBLOCK_MSG, I->getName());
dumpRequiredSet(BP);
initializeAnalysisImpl(BP);
if (Changed)
dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG,
- I->getNameStart());
+ I->getName());
dumpPreservedSet(BP);
verifyPreservedAnalysis(BP);
removeNotPreservedAnalysis(BP);
recordAvailableAnalysis(BP);
- removeDeadPasses(BP, I->getNameStart(), ON_BASICBLOCK_MSG);
+ removeDeadPasses(BP, I->getName(), ON_BASICBLOCK_MSG);
}
return Changed |= doFinalization(F);
bool FunctionPassManager::run(Function &F) {
std::string errstr;
if (MP->materializeFunction(&F, &errstr)) {
- cerr << "Error reading bitcode file: " << errstr << "\n";
- abort();
+ llvm_report_error("Error reading bitcode file: " + errstr);
}
return FPM->run(F);
}
char FPPassManager::ID = 0;
/// Print passes managed by this manager
void FPPassManager::dumpPassStructure(unsigned Offset) {
- llvm::cerr << std::string(Offset*2, ' ') << "FunctionPass Manager\n";
+ llvm::errs() << std::string(Offset*2, ' ') << "FunctionPass Manager\n";
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
FunctionPass *FP = getContainedPass(Index);
FP->dumpPassStructure(Offset + 1);
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
FunctionPass *FP = getContainedPass(Index);
- dumpPassInfo(FP, EXECUTION_MSG, ON_FUNCTION_MSG, F.getNameStart());
+ dumpPassInfo(FP, EXECUTION_MSG, ON_FUNCTION_MSG, F.getName());
dumpRequiredSet(FP);
initializeAnalysisImpl(FP);
}
if (Changed)
- dumpPassInfo(FP, MODIFICATION_MSG, ON_FUNCTION_MSG, F.getNameStart());
+ dumpPassInfo(FP, MODIFICATION_MSG, ON_FUNCTION_MSG, F.getName());
dumpPreservedSet(FP);
verifyPreservedAnalysis(FP);
removeNotPreservedAnalysis(FP);
recordAvailableAnalysis(FP);
- removeDeadPasses(FP, F.getNameStart(), ON_FUNCTION_MSG);
+ removeDeadPasses(FP, F.getName(), ON_FUNCTION_MSG);
// If dominator information is available then verify the info if requested.
verifyDomInfo(*FP, F);
}
/// If TimingInfo is enabled then start pass timer.
-void StartPassTimer(Pass *P) {
+void llvm::StartPassTimer(Pass *P) {
if (TheTimeInfo)
TheTimeInfo->passStarted(P);
}
/// If TimingInfo is enabled then stop pass timer.
-void StopPassTimer(Pass *P) {
+void llvm::StopPassTimer(Pass *P) {
if (TheTimeInfo)
TheTimeInfo->passEnded(P);
}