From: Bill Wendling Date: Sun, 26 Nov 2006 10:02:32 +0000 (+0000) Subject: Replace #include with llvm_* streams. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0a81aac4b46eed130d20714af5a1c01b05d0275e;p=oota-llvm.git Replace #include with llvm_* streams. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31924 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 646f5b8e08e..e9841697a78 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -44,7 +44,6 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" -#include #include using namespace llvm; @@ -231,9 +230,9 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg) const { if (std::find(GEPIndices.begin(), GEPIndices.end(), Operands) == GEPIndices.end()) { if (GEPIndices.size() == 3) { - DEBUG(std::cerr << "argpromotion disable promoting argument '" - << Arg->getName() << "' because it would require adding more " - << "than 3 arguments to the function.\n"); + DOUT << "argpromotion disable promoting argument '" + << Arg->getName() << "' because it would require adding more " + << "than 3 arguments to the function.\n"; // We limit aggregate promotion to only promoting up to three elements // of the aggregate. return false; @@ -501,8 +500,8 @@ Function *ArgPromotion::DoPromotion(Function *F, LI->replaceAllUsesWith(I2); AA.replaceWithNewValue(LI, I2); LI->getParent()->getInstList().erase(LI); - DEBUG(std::cerr << "*** Promoted load of argument '" << I->getName() - << "' in function '" << F->getName() << "'\n"); + DOUT << "*** Promoted load of argument '" << I->getName() + << "' in function '" << F->getName() << "'\n"; } else { GetElementPtrInst *GEP = cast(I->use_back()); std::vector Operands(GEP->op_begin()+1, GEP->op_end()); @@ -521,8 +520,8 @@ Function *ArgPromotion::DoPromotion(Function *F, NewName += ".x"; TheArg->setName(NewName+".val"); - DEBUG(std::cerr << "*** Promoted agg argument '" << TheArg->getName() - << "' of function '" << F->getName() << "'\n"); + DOUT << "*** Promoted agg argument '" << TheArg->getName() + << "' of function '" << F->getName() << "'\n"; // All of the uses must be load instructions. Replace them all with // the argument specified by ArgNo. diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index f361d5b10b9..77ac8737b08 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -29,7 +29,6 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" -#include #include using namespace llvm; @@ -322,7 +321,7 @@ void DAE::SurveyFunction(Function &F) { } if (FunctionIntrinsicallyLive) { - DEBUG(std::cerr << " Intrinsically live fn: " << F.getName() << "\n"); + DOUT << " Intrinsically live fn: " << F.getName() << "\n"; for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI) LiveArguments.insert(AI); @@ -336,7 +335,7 @@ void DAE::SurveyFunction(Function &F) { case Dead: DeadRetVal.insert(&F); break; } - DEBUG(std::cerr << " Inspecting args for fn: " << F.getName() << "\n"); + DOUT << " Inspecting args for fn: " << F.getName() << "\n"; // If it is not intrinsically alive, we know that all users of the // function are call sites. Mark all of the arguments live which are @@ -348,16 +347,15 @@ void DAE::SurveyFunction(Function &F) { AI != E; ++AI) switch (getArgumentLiveness(*AI)) { case Live: - DEBUG(std::cerr << " Arg live by use: " << AI->getName() << "\n"); + DOUT << " Arg live by use: " << AI->getName() << "\n"; LiveArguments.insert(AI); break; case Dead: - DEBUG(std::cerr << " Arg definitely dead: " <getName()<<"\n"); + DOUT << " Arg definitely dead: " << AI->getName() <<"\n"; DeadArguments.insert(AI); break; case MaybeLive: - DEBUG(std::cerr << " Arg only passed to calls: " - << AI->getName() << "\n"); + DOUT << " Arg only passed to calls: " << AI->getName() << "\n"; AnyMaybeLiveArgs = true; MaybeLiveArguments.insert(AI); break; @@ -416,7 +414,7 @@ void DAE::MarkArgumentLive(Argument *Arg) { std::set::iterator It = MaybeLiveArguments.lower_bound(Arg); if (It == MaybeLiveArguments.end() || *It != Arg) return; - DEBUG(std::cerr << " MaybeLive argument now live: " << Arg->getName()<<"\n"); + DOUT << " MaybeLive argument now live: " << Arg->getName() <<"\n"; MaybeLiveArguments.erase(It); LiveArguments.insert(Arg); @@ -454,7 +452,7 @@ void DAE::MarkRetValLive(Function *F) { std::set::iterator I = MaybeLiveRetVal.lower_bound(F); if (I == MaybeLiveRetVal.end() || *I != F) return; // It's already alive! - DEBUG(std::cerr << " MaybeLive retval now live: " << F->getName() << "\n"); + DOUT << " MaybeLive retval now live: " << F->getName() << "\n"; MaybeLiveRetVal.erase(I); LiveRetVal.insert(F); // It is now known to be live! @@ -611,7 +609,7 @@ bool DAE::runOnModule(Module &M) { // We assume all arguments are dead unless proven otherwise (allowing us to // determine that dead arguments passed into recursive functions are dead). // - DEBUG(std::cerr << "DAE - Determining liveness\n"); + DOUT << "DAE - Determining liveness\n"; for (Module::iterator I = M.begin(), E = M.end(); I != E; ) { Function &F = *I++; if (F.getFunctionType()->isVarArg()) diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 6cdd530a11d..bdec082cd06 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -28,7 +28,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include -#include #include using namespace llvm; @@ -425,7 +424,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { if (NewGlobals.empty()) return 0; - DEBUG(std::cerr << "PERFORMING GLOBAL SRA ON: " << *GV); + DOUT << "PERFORMING GLOBAL SRA ON: " << *GV; Constant *NullInt = Constant::getNullValue(Type::IntTy); @@ -495,17 +494,17 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) { // Will trap. } else if (StoreInst *SI = dyn_cast(*UI)) { if (SI->getOperand(0) == V) { - //std::cerr << "NONTRAPPING USE: " << **UI; + //llvm_cerr << "NONTRAPPING USE: " << **UI; return false; // Storing the value. } } else if (CallInst *CI = dyn_cast(*UI)) { if (CI->getOperand(0) != V) { - //std::cerr << "NONTRAPPING USE: " << **UI; + //llvm_cerr << "NONTRAPPING USE: " << **UI; return false; // Not calling the ptr } } else if (InvokeInst *II = dyn_cast(*UI)) { if (II->getOperand(0) != V) { - //std::cerr << "NONTRAPPING USE: " << **UI; + //llvm_cerr << "NONTRAPPING USE: " << **UI; return false; // Not calling the ptr } } else if (CastInst *CI = dyn_cast(*UI)) { @@ -516,7 +515,7 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) { isa(UI->getOperand(1))) { // Ignore setcc X, null } else { - //std::cerr << "NONTRAPPING USE: " << **UI; + //llvm_cerr << "NONTRAPPING USE: " << **UI; return false; } return true; @@ -534,7 +533,7 @@ static bool AllUsesOfLoadedValueWillTrapIfNull(GlobalVariable *GV) { // Ignore stores to the global. } else { // We don't know or understand this user, bail out. - //std::cerr << "UNKNOWN USER OF GLOBAL!: " << **UI; + //llvm_cerr << "UNKNOWN USER OF GLOBAL!: " << **UI; return false; } @@ -620,7 +619,7 @@ static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV) { } if (Changed) { - DEBUG(std::cerr << "OPTIMIZED LOADS FROM STORED ONCE POINTER: " << *GV); + DOUT << "OPTIMIZED LOADS FROM STORED ONCE POINTER: " << *GV; ++NumGlobUses; } @@ -640,7 +639,7 @@ static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV) { // If we nuked all of the loads, then none of the stores are needed either, // nor is the global. if (AllLoadsGone) { - DEBUG(std::cerr << " *** GLOBAL NOW DEAD!\n"); + DOUT << " *** GLOBAL NOW DEAD!\n"; CleanupConstantGlobalUsers(GV, 0); if (GV->use_empty()) { GV->eraseFromParent(); @@ -674,7 +673,7 @@ static void ConstantPropUsersOf(Value *V) { /// malloc into a global, and any laods of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, MallocInst *MI) { - DEBUG(std::cerr << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " <<*MI); + DOUT << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " << *MI; ConstantInt *NElements = cast(MI->getArraySize()); if (NElements->getZExtValue() != 1) { @@ -918,7 +917,7 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr, /// PerformHeapAllocSRoA - MI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){ - DEBUG(std::cerr << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *MI); + DOUT << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *MI; const StructType *STy = cast(MI->getAllocatedType()); // There is guaranteed to be at least one use of the malloc (storing @@ -1196,7 +1195,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, GV->removeDeadConstantUsers(); if (GV->use_empty()) { - DEBUG(std::cerr << "GLOBAL DEAD: " << *GV); + DOUT << "GLOBAL DEAD: " << *GV; GV->eraseFromParent(); ++NumDeleted; return true; @@ -1204,25 +1203,25 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, if (!AnalyzeGlobal(GV, GS, PHIUsers)) { #if 0 - std::cerr << "Global: " << *GV; - std::cerr << " isLoaded = " << GS.isLoaded << "\n"; - std::cerr << " StoredType = "; + llvm_cerr << "Global: " << *GV; + llvm_cerr << " isLoaded = " << GS.isLoaded << "\n"; + llvm_cerr << " StoredType = "; switch (GS.StoredType) { - case GlobalStatus::NotStored: std::cerr << "NEVER STORED\n"; break; - case GlobalStatus::isInitializerStored: std::cerr << "INIT STORED\n"; break; - case GlobalStatus::isStoredOnce: std::cerr << "STORED ONCE\n"; break; - case GlobalStatus::isStored: std::cerr << "stored\n"; break; + case GlobalStatus::NotStored: llvm_cerr << "NEVER STORED\n"; break; + case GlobalStatus::isInitializerStored: llvm_cerr << "INIT STORED\n"; break; + case GlobalStatus::isStoredOnce: llvm_cerr << "STORED ONCE\n"; break; + case GlobalStatus::isStored: llvm_cerr << "stored\n"; break; } if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue) - std::cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; + llvm_cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions) - std::cerr << " AccessingFunction = " << GS.AccessingFunction->getName() + llvm_cerr << " AccessingFunction = " << GS.AccessingFunction->getName() << "\n"; - std::cerr << " HasMultipleAccessingFunctions = " + llvm_cerr << " HasMultipleAccessingFunctions = " << GS.HasMultipleAccessingFunctions << "\n"; - std::cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; - std::cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n"; - std::cerr << "\n"; + llvm_cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; + llvm_cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n"; + llvm_cerr << "\n"; #endif // If this is a first class global and has only one accessing function @@ -1237,7 +1236,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, GV->getType()->getElementType()->isFirstClassType() && GS.AccessingFunction->getName() == "main" && GS.AccessingFunction->hasExternalLinkage()) { - DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV); + DOUT << "LOCALIZING GLOBAL: " << *GV; Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); const Type* ElemTy = GV->getType()->getElementType(); // FIXME: Pass Global's alignment when globals have alignment @@ -1254,7 +1253,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, // If the global is never loaded (but may be stored to), it is dead. // Delete it now. if (!GS.isLoaded) { - DEBUG(std::cerr << "GLOBAL NEVER LOADED: " << *GV); + DOUT << "GLOBAL NEVER LOADED: " << *GV; // Delete any stores we can find to the global. We may not be able to // make it completely dead though. @@ -1269,7 +1268,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, return Changed; } else if (GS.StoredType <= GlobalStatus::isInitializerStored) { - DEBUG(std::cerr << "MARKING CONSTANT: " << *GV); + DOUT << "MARKING CONSTANT: " << *GV; GV->setConstant(true); // Clean up any obviously simplifiable users now. @@ -1277,8 +1276,8 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, // If the global is dead now, just nuke it. if (GV->use_empty()) { - DEBUG(std::cerr << " *** Marking constant allowed us to simplify " - "all users and delete global!\n"); + DOUT << " *** Marking constant allowed us to simplify " + << "all users and delete global!\n"; GV->eraseFromParent(); ++NumDeleted; } @@ -1305,8 +1304,8 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, CleanupConstantGlobalUsers(GV, GV->getInitializer()); if (GV->use_empty()) { - DEBUG(std::cerr << " *** Substituting initializer allowed us to " - "simplify all users and delete global!\n"); + DOUT << " *** Substituting initializer allowed us to " + << "simplify all users and delete global!\n"; GV->eraseFromParent(); ++NumDeleted; } else { @@ -1328,7 +1327,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, if (GV->getType()->getElementType() != Type::BoolTy && !GV->getType()->getElementType()->isFloatingPoint() && !GS.HasPHIUser) { - DEBUG(std::cerr << " *** SHRINKING TO BOOL: " << *GV); + DOUT << " *** SHRINKING TO BOOL: " << *GV; ShrinkGlobalToBoolean(GV, SOVConstant); ++NumShrunkToBool; return true; @@ -1851,8 +1850,9 @@ static bool EvaluateStaticConstructor(Function *F) { CallStack, MutatedMemory, AllocaTmps); if (EvalSuccess) { // We succeeded at evaluation: commit the result. - DEBUG(std::cerr << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" << - F->getName() << "' to " << MutatedMemory.size() << " stores.\n"); + DOUT << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" + << F->getName() << "' to " << MutatedMemory.size() + << " stores.\n"; for (std::map::iterator I = MutatedMemory.begin(), E = MutatedMemory.end(); I != E; ++I) CommitValueTo(I->second, I->first); diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index ef27cd61a9a..c993f70cec0 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -24,7 +24,6 @@ #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" #include -#include #include using namespace llvm; diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index ef239bd7b97..ea43dc21da3 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -22,7 +22,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" -#include #include using namespace llvm; @@ -48,8 +47,7 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG, // function body now. if (Callee->use_empty() && Callee->hasInternalLinkage() && !SCCFunctions.count(Callee)) { - DEBUG(std::cerr << " -> Deleting dead function: " - << Callee->getName() << "\n"); + DOUT << " -> Deleting dead function: " << Callee->getName() << "\n"; // Remove any call graph edges from the callee to its callees. CallGraphNode *CalleeNode = CG[Callee]; @@ -67,11 +65,11 @@ bool Inliner::runOnSCC(const std::vector &SCC) { CallGraph &CG = getAnalysis(); std::set SCCFunctions; - DEBUG(std::cerr << "Inliner visiting SCC:"); + DOUT << "Inliner visiting SCC:"; for (unsigned i = 0, e = SCC.size(); i != e; ++i) { Function *F = SCC[i]->getFunction(); if (F) SCCFunctions.insert(F); - DEBUG(std::cerr << " " << (F ? F->getName() : "INDIRECTNODE")); + DOUT << " " << (F ? F->getName() : "INDIRECTNODE"); } // Scan through and identify all call sites ahead of time so that we only @@ -89,7 +87,7 @@ bool Inliner::runOnSCC(const std::vector &SCC) { CallSites.push_back(CS); } - DEBUG(std::cerr << ": " << CallSites.size() << " call sites.\n"); + DOUT << ": " << CallSites.size() << " call sites.\n"; // Now that we have all of the call sites, move the ones to functions in the // current SCC to the end of the list. @@ -128,11 +126,11 @@ bool Inliner::runOnSCC(const std::vector &SCC) { CallSite CS = CallSites[CSi]; int InlineCost = getInlineCost(CS); if (InlineCost >= (int)InlineThreshold) { - DEBUG(std::cerr << " NOT Inlining: cost=" << InlineCost - << ", Call: " << *CS.getInstruction()); + DOUT << " NOT Inlining: cost=" << InlineCost + << ", Call: " << *CS.getInstruction(); } else { - DEBUG(std::cerr << " Inlining: cost=" << InlineCost - << ", Call: " << *CS.getInstruction()); + DOUT << " Inlining: cost=" << InlineCost + << ", Call: " << *CS.getInstruction(); // Attempt to inline the function... if (InlineCallIfPossible(CS, CG, SCCFunctions)) { diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 9cece19cd75..c19e2f2b99c 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -20,7 +20,6 @@ #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" #include -#include #include using namespace llvm; @@ -75,8 +74,8 @@ 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"; + llvm_cerr << "WARNING: Internalize couldn't load file '" << Filename + << "'!\n"; return; // Do not internalize anything... } while (In) { @@ -113,7 +112,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 @@ -151,7 +150,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;