#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
return VMCI->second;
}
- DEBUG(std::cerr << "CETT: " << (void*)V << " " << *V);
+ DOUT << "CETT: " << (void*)V << " " << *V;
Instruction *I = dyn_cast<Instruction>(V);
if (I == 0) {
if (NumUses == OldSize) ++It;
}
- DEBUG(std::cerr << "ExpIn: " << (void*)I << " " << *I
- << "ExpOut: " << (void*)Res << " " << *Res);
+ DOUT << "ExpIn: " << (void*)I << " " << *I
+ << "ExpOut: " << (void*)Res << " " << *Res;
return Res;
}
I->setName("");
Instruction *Res; // Result of conversion
- //std::cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I
+ //llvm_cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I
// << "BB Before: " << BB << endl;
// Prevent I from being removed...
assert(It != BB->end() && "Instruction not in own basic block??");
BB->getInstList().insert(It, Res); // Keep It pointing to old instruction
- DEBUG(std::cerr << "COT CREATED: " << (void*)Res << " " << *Res
- << "In: " << (void*)I << " " << *I << "Out: " << (void*)Res
- << " " << *Res);
+ DOUT << "COT CREATED: " << (void*)Res << " " << *Res
+ << "In: " << (void*)I << " " << *I << "Out: " << (void*)Res
+ << " " << *Res;
// Add the instruction to the expression map
VMC.ExprMap[I] = Res;
ValueHandle::ValueHandle(ValueMapCache &VMC, Value *V)
: Instruction(Type::VoidTy, UserOp1, &Op, 1, ""), Op(V, this), Cache(VMC) {
- //DEBUG(std::cerr << "VH AQUIRING: " << (void*)V << " " << V);
+ //DOUT << "VH AQUIRING: " << (void*)V << " " << V;
}
ValueHandle::ValueHandle(const ValueHandle &VH)
: Instruction(Type::VoidTy, UserOp1, &Op, 1, ""),
Op(VH.Op, this), Cache(VH.Cache) {
- //DEBUG(std::cerr << "VH AQUIRING: " << (void*)V << " " << V);
+ //DOUT << "VH AQUIRING: " << (void*)V << " " << V;
}
static void RecursiveDelete(ValueMapCache &Cache, Instruction *I) {
assert(I->getParent() && "Inst not in basic block!");
- //DEBUG(std::cerr << "VH DELETING: " << (void*)I << " " << I);
+ //DOUT << "VH DELETING: " << (void*)I << " " << I;
for (User::op_iterator OI = I->op_begin(), OE = I->op_end();
OI != OE; ++OI)
//
RecursiveDelete(Cache, dyn_cast<Instruction>(V));
} else {
- //DEBUG(std::cerr << "VH RELEASING: " << (void*)Operands[0].get() << " "
- // << Operands[0]->getNumUses() << " " << Operands[0]);
+ //DOUT << "VH RELEASING: " << (void*)Operands[0].get() << " "
+ // << Operands[0]->getNumUses() << " " << Operands[0];
}
}
-
#include "llvm/Function.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/SlowOperationInformer.h"
+#include "llvm/Support/Streams.h"
#include "llvm/ADT/Statistic.h"
-#include <iostream>
using namespace llvm;
namespace {
HelloCounter++;
std::string fname = F.getName();
EscapeString(fname);
- std::cerr << "Hello: " << fname << "\n";
+ llvm_cerr << "Hello: " << fname << "\n";
return false;
}
};
HelloCounter++;
std::string fname = F.getName();
EscapeString(fname);
- std::cerr << "Hello: " << fname << "\n";
+ llvm_cerr << "Hello: " << fname << "\n";
return false;
}
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
+#include "llvm/Support/Streams.h"
#include "llvm/Transforms/Instrumentation.h"
#include "RSProfiling.h"
#include "ProfilingUtils.h"
-#include <iostream>
-
using namespace llvm;
namespace {
bool FunctionProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction();
if (Main == 0) {
- std::cerr << "WARNING: cannot insert function profiling into a module"
+ llvm_cerr << "WARNING: cannot insert function profiling into a module"
<< " with no main function!\n";
return false; // No main, no instrumentation!
}
bool BlockProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction();
if (Main == 0) {
- std::cerr << "WARNING: cannot insert block profiling into a module"
+ llvm_cerr << "WARNING: cannot insert block profiling into a module"
<< " with no main function!\n";
return false; // No main, no instrumentation!
}
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
+#include "llvm/Support/Streams.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Instrumentation.h"
#include "ProfilingUtils.h"
-#include <iostream>
#include <set>
using namespace llvm;
bool EdgeProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction();
if (Main == 0) {
- std::cerr << "WARNING: cannot insert edge profiling into a module"
+ llvm_cerr << "WARNING: cannot insert edge profiling into a module"
<< " with no main function!\n";
return false; // No main, no instrumentation!
}
#include "llvm/Transforms/Instrumentation.h"
//#include "ProfilingUtils.h"
#include "RSProfiling.h"
-
#include <set>
#include <map>
#include <queue>
#include <list>
-#include <iostream>
-
using namespace llvm;
namespace {
std::map<BasicBlock*, int> finish;
int time = 0;
recBackEdge(&F.getEntryBlock(), BackEdges, color, depth, finish, time);
- DEBUG(std::cerr << F.getName() << " " << BackEdges.size() << "\n");
+ DOUT << F.getName() << " " << BackEdges.size() << "\n";
}
#include "ProfilingUtils.h"
#include "llvm/Support/Debug.h"
#include <set>
-#include <iostream>
using namespace llvm;
namespace {
static void InsertInstrumentationCall (BasicBlock *BB,
const std::string FnName,
unsigned BBNumber) {
- DEBUG (std::cerr << "InsertInstrumentationCall (\"" << BB->getName ()
- << "\", \"" << FnName << "\", " << BBNumber << ")\n");
+ DOUT << "InsertInstrumentationCall (\"" << BB->getName ()
+ << "\", \"" << FnName << "\", " << BBNumber << ")\n";
Module &M = *BB->getParent ()->getParent ();
Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
Type::UIntTy, (Type *)0);
bool TraceBasicBlocks::runOnModule(Module &M) {
Function *Main = M.getMainFunction();
if (Main == 0) {
- std::cerr << "WARNING: cannot insert basic-block trace instrumentation"
+ llvm_cerr << "WARNING: cannot insert basic-block trace instrumentation"
<< " into a module with no main function!\n";
return false; // No main, no instrumentation!
}
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
-#include <iostream>
using namespace llvm;
// StartInst - This enables the -raise-start-inst=foo option to cause the level
NumVarargCallChanges("raise", "Number of vararg call peepholes");
#define PRINT_PEEPHOLE(ID, NUM, I) \
- DEBUG(std::cerr << "Inst P/H " << ID << "[" << NUM << "] " << I)
+ DOUT << "Inst P/H " << ID << "[" << NUM << "] " << I
#define PRINT_PEEPHOLE1(ID, I1) do { PRINT_PEEPHOLE(ID, 0, I1); } while (0)
#define PRINT_PEEPHOLE2(ID, I1, I2) \
if (ExpressionConvertibleToType(Src, DestTy, ConvertedTypes, TD)) {
PRINT_PEEPHOLE3("CAST-SRC-EXPR-CONV:in ", *Src, *CI, *BB->getParent());
- DEBUG(std::cerr << "\nCONVERTING SRC EXPR TYPE:\n");
+ DOUT << "\nCONVERTING SRC EXPR TYPE:\n";
{ // ValueMap must be destroyed before function verified!
ValueMapCache ValueMap;
Value *E = ConvertExpressionToType(Src, DestTy, ValueMap, TD);
CI->replaceAllUsesWith(CPV);
PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", *E);
- DEBUG(std::cerr << "DONE CONVERTING SRC EXPR TYPE: \n"
- << *BB->getParent());
+ DOUT << "DONE CONVERTING SRC EXPR TYPE: \n"
+ << *BB->getParent();
}
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
//PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI,
// *BB->getParent());
- DEBUG(std::cerr << "\nCONVERTING EXPR TYPE:\n");
+ DOUT << "\nCONVERTING EXPR TYPE:\n";
{ // ValueMap must be destroyed before function verified!
ValueMapCache ValueMap;
ConvertValueToNewType(CI, Src, ValueMap, TD); // This will delete CI!
}
PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", *Src);
- DEBUG(std::cerr << "DONE CONVERTING EXPR TYPE: \n\n" <<
- *BB->getParent());
+ DOUT << "DONE CONVERTING EXPR TYPE: \n\n" << *BB->getParent();
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
++NumExprTreesConv;
bool Changed = false;
for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB)
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
- DEBUG(std::cerr << "LevelRaising: " << *BI);
+ DOUT << "LevelRaising: " << *BI;
if (dceInstruction(BI) || doConstantPropagation(BI)) {
Changed = true;
++NumDCEorCP;
- DEBUG(std::cerr << "***\t\t^^-- Dead code eliminated!\n");
+ DOUT << "***\t\t^^-- Dead code eliminated!\n";
} else if (PeepholeOptimize(BB, BI)) {
Changed = true;
} else {
// runOnFunction - Raise a function representation to a higher level.
bool RPR::runOnFunction(Function &F) {
- DEBUG(std::cerr << "\n\n\nStarting to work on Function '" << F.getName()
- << "'\n");
+ DOUT << "\n\n\nStarting to work on Function '" << F.getName() << "'\n";
// Insert casts for all incoming pointer pointer values that are treated as
// arrays...
}
do {
- DEBUG(std::cerr << "Looping: \n" << F);
+ DOUT << "Looping: \n" << F;
// Iterate over the function, refining it, until it converges on a stable
// state