[llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp DeadArgumentElimination.cpp GlobalOpt.cpp IndMemRemoval.cpp Inliner.cpp Internalize.cpp
Bill Wendling
isanbard at gmail.com
Sun Nov 26 02:02:49 PST 2006
Changes in directory llvm/lib/Transforms/IPO:
ArgumentPromotion.cpp updated: 1.29 -> 1.30
DeadArgumentElimination.cpp updated: 1.29 -> 1.30
GlobalOpt.cpp updated: 1.71 -> 1.72
IndMemRemoval.cpp updated: 1.4 -> 1.5
Inliner.cpp updated: 1.32 -> 1.33
Internalize.cpp updated: 1.36 -> 1.37
---
Log message:
Replace #include <iostream> with llvm_* streams.
---
Diffs of the changes: (+62 -69)
ArgumentPromotion.cpp | 15 ++++-----
DeadArgumentElimination.cpp | 18 +++++------
GlobalOpt.cpp | 70 ++++++++++++++++++++++----------------------
IndMemRemoval.cpp | 1
Inliner.cpp | 18 +++++------
Internalize.cpp | 9 ++---
6 files changed, 62 insertions(+), 69 deletions(-)
Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.29 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.30
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.29 Thu Nov 2 14:25:50 2006
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp Sun Nov 26 04:02:32 2006
@@ -44,7 +44,6 @@
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
-#include <iostream>
#include <set>
using namespace llvm;
@@ -231,9 +230,9 @@
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 @@
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<GetElementPtrInst>(I->use_back());
std::vector<Value*> Operands(GEP->op_begin()+1, GEP->op_end());
@@ -521,8 +520,8 @@
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.
Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.29 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.30
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.29 Mon Sep 18 02:02:31 2006
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp Sun Nov 26 04:02:32 2006
@@ -29,7 +29,6 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
#include <set>
using namespace llvm;
@@ -322,7 +321,7 @@
}
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 @@
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 @@
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: " <<AI->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 @@
std::set<Argument*>::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 @@
std::set<Function*>::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 @@
// 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())
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.71 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.72
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.71 Thu Nov 2 14:25:50 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Sun Nov 26 04:02:32 2006
@@ -28,7 +28,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
-#include <iostream>
#include <set>
using namespace llvm;
@@ -425,7 +424,7 @@
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 @@
// Will trap.
} else if (StoreInst *SI = dyn_cast<StoreInst>(*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<CallInst>(*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<InvokeInst>(*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<CastInst>(*UI)) {
@@ -516,7 +515,7 @@
isa<ConstantPointerNull>(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 @@
// 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 @@
}
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 @@
// 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 @@
/// 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<ConstantInt>(MI->getArraySize());
if (NElements->getZExtValue() != 1) {
@@ -918,7 +917,7 @@
/// 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<StructType>(MI->getAllocatedType());
// There is guaranteed to be at least one use of the malloc (storing
@@ -1196,7 +1195,7 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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<Constant*, Constant*>::iterator I = MutatedMemory.begin(),
E = MutatedMemory.end(); I != E; ++I)
CommitValueTo(I->second, I->first);
Index: llvm/lib/Transforms/IPO/IndMemRemoval.cpp
diff -u llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.4 llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.5
--- llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.4 Thu Nov 2 14:25:50 2006
+++ llvm/lib/Transforms/IPO/IndMemRemoval.cpp Sun Nov 26 04:02:32 2006
@@ -24,7 +24,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <fstream>
-#include <iostream>
#include <set>
using namespace llvm;
Index: llvm/lib/Transforms/IPO/Inliner.cpp
diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.32 llvm/lib/Transforms/IPO/Inliner.cpp:1.33
--- llvm/lib/Transforms/IPO/Inliner.cpp:1.32 Thu Nov 9 17:36:08 2006
+++ llvm/lib/Transforms/IPO/Inliner.cpp Sun Nov 26 04:02:32 2006
@@ -22,7 +22,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
#include <set>
using namespace llvm;
@@ -48,8 +47,7 @@
// 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 @@
CallGraph &CG = getAnalysis<CallGraph>();
std::set<Function*> 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 @@
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 @@
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)) {
Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.36 llvm/lib/Transforms/IPO/Internalize.cpp:1.37
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.36 Tue Sep 12 20:02:26 2006
+++ llvm/lib/Transforms/IPO/Internalize.cpp Sun Nov 26 04:02:32 2006
@@ -20,7 +20,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <fstream>
-#include <iostream>
#include <set>
using namespace llvm;
@@ -75,8 +74,8 @@
// 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 @@
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 @@
I->setLinkage(GlobalValue::InternalLinkage);
Changed = true;
++NumGlobals;
- DEBUG(std::cerr << "Internalized gvar " << I->getName() << "\n");
+ DOUT << "Internalized gvar " << I->getName() << "\n";
}
return Changed;
More information about the llvm-commits
mailing list