For PR1043:
[oota-llvm.git] / lib / Transforms / IPO / Internalize.cpp
index 2eec95ff618cde9993299fbe64fbd421b2d50fb8..bf99235fb8b00b1057777894ca60aa6388ac91ef 100644 (file)
@@ -13,6 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "internalize"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Pass.h"
 #include "llvm/Module.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
 #include <fstream>
-#include <iostream>
 #include <set>
 using namespace llvm;
 
+STATISTIC(NumFunctions, "Number of functions internalized");
+STATISTIC(NumGlobals  , "Number of global vars internalized");
+
 namespace {
-  Statistic<> NumFunctions("internalize", "Number of functions internalized");
-  Statistic<> NumGlobals  ("internalize", "Number of global vars internalized");
 
   // APIFile - A file which contains a list of symbols that should not be marked
   // external.
@@ -63,7 +64,8 @@ InternalizePass::InternalizePass(bool InternalizeEverything)
     DontInternalize = true;
 }
 
-InternalizePass::InternalizePass(const std::vector<const char *>&exportList) {
+InternalizePass::InternalizePass(const std::vector<const char *>&exportList) 
+  : DontInternalize(false){
   for(std::vector<const char *>::const_iterator itr = exportList.begin();
        itr != exportList.end(); itr++) {
     ExternalNames.insert(*itr);
@@ -74,8 +76,7 @@ void InternalizePass::LoadFile(const char *Filename) {
   // Load the APIFile...
   std::ifstream In(Filename);
   if (!In.good()) {
-    std::cerr << "WARNING: Internalize couldn't load file '" << Filename
-    << "'!\n";
+    cerr << "WARNING: Internalize couldn't load file '" << Filename << "'!\n";
     return;   // Do not internalize anything...
   }
   while (In) {
@@ -112,7 +113,7 @@ bool InternalizePass::runOnModule(Module &M) {
       I->setLinkage(GlobalValue::InternalLinkage);
       Changed = true;
       ++NumFunctions;
-      DEBUG(std::cerr << "Internalizing func " << I->getName() << "\n");
+      DOUT << "Internalizing func " << I->getName() << "\n";
     }
   
   // Never internalize the llvm.used symbol.  It is used to implement
@@ -150,7 +151,7 @@ bool InternalizePass::runOnModule(Module &M) {
       I->setLinkage(GlobalValue::InternalLinkage);
       Changed = true;
       ++NumGlobals;
-      DEBUG(std::cerr << "Internalized gvar " << I->getName() << "\n");
+      DOUT << "Internalized gvar " << I->getName() << "\n";
     }
       
   return Changed;