What should be the last unnecessary <iostream>s in the library.
[oota-llvm.git] / lib / Transforms / IPO / FunctionResolution.cpp
index 8b5019a0afc8f5e8ca683a901809017475b75197..f6e8cf591344129b7810a47a7fcf509ff94fff71 100644 (file)
@@ -32,8 +32,8 @@
 using namespace llvm;
 
 namespace {
-  Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved");
-  Statistic<> NumGlobals("funcresolve", "Number of global variables resolved");
+  Statistic NumResolved("funcresolve", "Number of varargs functions resolved");
+  Statistic NumGlobals("funcresolve", "Number of global variables resolved");
 
   struct FunctionResolvingPass : public ModulePass {
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -42,7 +42,7 @@ namespace {
 
     bool runOnModule(Module &M);
   };
-  RegisterOpt<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
+  RegisterPass<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
 }
 
 ModulePass *llvm::createFunctionResolvingPass() {
@@ -55,38 +55,40 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals,
   for (unsigned i = 0; i != Globals.size(); ++i)
     if (Globals[i] != Concrete) {
       Function *Old = cast<Function>(Globals[i]);
-      const FunctionType *OldMT = Old->getFunctionType();
-      const FunctionType *ConcreteMT = Concrete->getFunctionType();
+      const FunctionType *OldFT = Old->getFunctionType();
+      const FunctionType *ConcreteFT = Concrete->getFunctionType();
 
-      if (OldMT->getNumParams() > ConcreteMT->getNumParams() &&
-          !ConcreteMT->isVarArg())
+      if (OldFT->getNumParams() > ConcreteFT->getNumParams() &&
+          !ConcreteFT->isVarArg())
         if (!Old->use_empty()) {
-          std::cerr << "WARNING: Linking function '" << Old->getName()
-                    << "' is causing arguments to be dropped.\n";
-          std::cerr << "WARNING: Prototype: ";
-          WriteAsOperand(std::cerr, Old);
-          std::cerr << " resolved to ";
-          WriteAsOperand(std::cerr, Concrete);
-          std::cerr << "\n";
+          cerr << "WARNING: Linking function '" << Old->getName()
+               << "' is causing arguments to be dropped.\n";
+          cerr << "WARNING: Prototype: ";
+          WriteAsOperand(*cerr.stream(), Old);
+          cerr << " resolved to ";
+          WriteAsOperand(*cerr.stream(), Concrete);
+          cerr << "\n";
         }
 
       // Check to make sure that if there are specified types, that they
       // match...
       //
-      unsigned NumArguments = std::min(OldMT->getNumParams(),
-                                       ConcreteMT->getNumParams());
+      unsigned NumArguments = std::min(OldFT->getNumParams(),
+                                       ConcreteFT->getNumParams());
 
       if (!Old->use_empty() && !Concrete->use_empty())
         for (unsigned i = 0; i < NumArguments; ++i)
-          if (OldMT->getParamType(i) != ConcreteMT->getParamType(i))
-            if (OldMT->getParamType(i)->getTypeID() !=
-                ConcreteMT->getParamType(i)->getTypeID()) {
-              std::cerr << "WARNING: Function [" << Old->getName()
-                        << "]: Parameter types conflict for: '";
-              WriteTypeSymbolic(std::cerr, OldMT, &M);
-              std::cerr << "' and '";
-              WriteTypeSymbolic(std::cerr, ConcreteMT, &M);
-              std::cerr << "'\n";
+          if (OldFT->getParamType(i) != ConcreteFT->getParamType(i))
+            if (OldFT->getParamType(i)->getTypeID() !=
+                ConcreteFT->getParamType(i)->getTypeID()) {
+              cerr << "WARNING: Function [" << Old->getName()
+                   << "]: Parameter types conflict for: '";
+              WriteTypeSymbolic(*cerr.stream(), OldFT, &M);
+              cerr << "' (in " 
+                   << Old->getParent()->getModuleIdentifier() << ") and '";
+              WriteTypeSymbolic(*cerr.stream(), ConcreteFT, &M);
+              cerr << "'(in " 
+                   << Concrete->getParent()->getModuleIdentifier() << ")\n";
               return Changed;
             }
 
@@ -161,8 +163,8 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
 
   for (unsigned i = 0; i != Globals.size(); ) {
     if (isa<Function>(Globals[i]) != isFunction) {
-      std::cerr << "WARNING: Found function and global variable with the "
-                << "same name: '" << Globals[i]->getName() << "'.\n";
+      cerr << "WARNING: Found function and global variable with the "
+           << "same name: '" << Globals[i]->getName() << "'.\n";
       return false;                 // Don't know how to handle this, bail out!
     }
 
@@ -189,9 +191,9 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
       GlobalVariable *GV = cast<GlobalVariable>(Globals[i]);
       if (!GV->isExternal()) {
         if (Concrete) {
-          std::cerr << "WARNING: Two global variables with external linkage"
-                    << " exist with the same name: '" << GV->getName()
-                    << "'!\n";
+          cerr << "WARNING: Two global variables with external linkage"
+               << " exist with the same name: '" << GV->getName()
+               << "'!\n";
           return false;
         }
         Concrete = GV;
@@ -248,11 +250,11 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
     }
 
     if (0 && !DontPrintWarning) {
-      std::cerr << "WARNING: Found global types that are not compatible:\n";
+      cerr << "WARNING: Found global types that are not compatible:\n";
       for (unsigned i = 0; i < Globals.size(); ++i) {
-        std::cerr << "\t";
-        WriteTypeSymbolic(std::cerr, Globals[i]->getType(), &M);
-        std::cerr << " %" << Globals[i]->getName() << "\n";
+        cerr << "\t";
+        WriteTypeSymbolic(*cerr.stream(), Globals[i]->getType(), &M);
+        cerr << " %" << Globals[i]->getName() << "\n";
       }
     }
 
@@ -311,7 +313,8 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
       Globals[F->getName()].push_back(F);
   }
 
-  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ) {
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+       I != E; ) {
     GlobalVariable *GV = I++;
     if (GV->use_empty() && GV->isExternal()) {
       M.getGlobalList().erase(GV);
@@ -343,7 +346,8 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
       ++I;
     }
 
-  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; )
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+       I != E; )
     if (I->isExternal() && I->use_empty()) {
       GlobalVariable *GV = I;
       ++I;