[llvm-commits] [llvm] r79811 - in /llvm/trunk: include/llvm/CodeGen/MachineBasicBlock.h include/llvm/CodeGen/MachineFunction.h include/llvm/CodeGen/Passes.h lib/CodeGen/GCMetadata.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineBasicBlock.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineSink.cpp lib/CodeGen/MachineVerifier.cpp
Chris Lattner
sabre at nondot.org
Sat Aug 22 20:13:20 PDT 2009
Author: lattner
Date: Sat Aug 22 22:13:20 2009
New Revision: 79811
URL: http://llvm.org/viewvc/llvm-project?rev=79811&view=rev
Log:
remove std::ostream versions of printing stuff for MBB and MF,
upgrading a few things to use raw_ostream
Modified:
llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
llvm/trunk/include/llvm/CodeGen/Passes.h
llvm/trunk/lib/CodeGen/GCMetadata.cpp
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
llvm/trunk/lib/CodeGen/MachineFunction.cpp
llvm/trunk/lib/CodeGen/MachineSink.cpp
llvm/trunk/lib/CodeGen/MachineVerifier.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Sat Aug 22 22:13:20 2009
@@ -310,7 +310,6 @@
// Debugging methods.
void dump() const;
- void print(std::ostream &OS) const;
void print(raw_ostream &OS) const;
/// getNumber - MachineBasicBlocks are uniquely numbered at the function
@@ -339,7 +338,6 @@
void removePredecessor(MachineBasicBlock *pred);
};
-std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB);
raw_ostream& operator<<(raw_ostream &OS, const MachineBasicBlock &MBB);
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Sat Aug 22 22:13:20 2009
@@ -207,7 +207,6 @@
/// print - Print out the MachineFunction in a format suitable for debugging
/// to the specified stream.
///
- void print(std::ostream &OS) const;
void print(raw_ostream &OS) const;
/// viewCFG - This function is meant for use from the debugger. You can just
Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Sat Aug 22 22:13:20 2009
@@ -15,7 +15,6 @@
#ifndef LLVM_CODEGEN_PASSES_H
#define LLVM_CODEGEN_PASSES_H
-#include <iosfwd>
#include <string>
namespace llvm {
@@ -25,6 +24,7 @@
class TargetMachine;
class TargetLowering;
class RegisterCoalescer;
+ class raw_ostream;
/// createUnreachableBlockEliminationPass - The LLVM code generator does not
/// work well with unreachable basic blocks (what live ranges make sense for a
@@ -36,7 +36,7 @@
/// MachineFunctionPrinter pass - This pass prints out the machine function to
/// the given stream, as a debugging tool.
- FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
+ FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner ="");
/// MachineLoopInfo pass - This pass is a loop analysis pass.
@@ -166,7 +166,7 @@
/// Creates a pass to print GC metadata.
///
- FunctionPass *createGCInfoPrinter(std::ostream &OS);
+ FunctionPass *createGCInfoPrinter(raw_ostream &OS);
/// createMachineLICMPass - This pass performs LICM on machine instructions.
///
Modified: llvm/trunk/lib/CodeGen/GCMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCMetadata.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GCMetadata.cpp (original)
+++ llvm/trunk/lib/CodeGen/GCMetadata.cpp Sat Aug 22 22:13:20 2009
@@ -19,17 +19,19 @@
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
-
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
class VISIBILITY_HIDDEN Printer : public FunctionPass {
static char ID;
- std::ostream &OS;
+ raw_ostream &OS;
public:
- explicit Printer(std::ostream &OS = *cerr);
+ Printer() : FunctionPass(&ID), OS(errs()) {}
+ explicit Printer(raw_ostream &OS) : FunctionPass(&ID), OS(OS) {}
+
const char *getPassName() const;
void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -122,12 +124,10 @@
char Printer::ID = 0;
-FunctionPass *llvm::createGCInfoPrinter(std::ostream &OS) {
+FunctionPass *llvm::createGCInfoPrinter(raw_ostream &OS) {
return new Printer(OS);
}
-Printer::Printer(std::ostream &OS)
- : FunctionPass(&ID), OS(OS) {}
const char *Printer::getPassName() const {
return "Print Garbage Collector Information";
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Sat Aug 22 22:13:20 2009
@@ -78,10 +78,10 @@
PM.add(createDebugLabelFoldingPass());
if (PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (OptLevel != CodeGenOpt::None)
PM.add(createCodePlacementOptPass());
@@ -178,7 +178,7 @@
return true;
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
addCodeEmitter(PM, OptLevel, MCE);
if (PrintEmittedAsm)
@@ -203,7 +203,7 @@
return true;
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
addCodeEmitter(PM, OptLevel, JCE);
if (PrintEmittedAsm)
@@ -217,7 +217,7 @@
static void printAndVerify(PassManagerBase &PM,
bool allowDoubleDefs = false) {
if (PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (VerifyMachineCode)
PM.add(createMachineVerifierPass(allowDoubleDefs));
@@ -334,7 +334,7 @@
printAndVerify(PM);
if (PrintGCInfo)
- PM.add(createGCInfoPrinter(*cerr));
+ PM.add(createGCInfoPrinter(errs()));
return false;
}
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Sat Aug 22 22:13:20 2009
@@ -32,10 +32,6 @@
LeakDetector::removeGarbageObject(this);
}
-std::ostream &llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) {
- MBB.print(OS);
- return OS;
-}
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
MBB.print(OS);
return OS;
@@ -159,7 +155,7 @@
}
void MachineBasicBlock::dump() const {
- print(*cerr.stream());
+ print(errs());
}
static inline void OutputReg(raw_ostream &os, unsigned RegNo,
@@ -173,11 +169,6 @@
os << " %reg" << RegNo;
}
-void MachineBasicBlock::print(std::ostream &OS) const {
- raw_os_ostream RawOS(OS);
- print(RawOS);
-}
-
void MachineBasicBlock::print(raw_ostream &OS) const {
const MachineFunction *MF = getParent();
if (!MF) {
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Aug 22 22:13:20 2009
@@ -33,18 +33,16 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
-#include <fstream>
-#include <sstream>
using namespace llvm;
namespace {
struct VISIBILITY_HIDDEN Printer : public MachineFunctionPass {
static char ID;
- std::ostream *OS;
+ raw_ostream &OS;
const std::string Banner;
- Printer(std::ostream *os, const std::string &banner)
+ Printer(raw_ostream &os, const std::string &banner)
: MachineFunctionPass(&ID), OS(os), Banner(banner) {}
const char *getPassName() const { return "MachineFunction Printer"; }
@@ -55,8 +53,8 @@
}
bool runOnMachineFunction(MachineFunction &MF) {
- (*OS) << Banner;
- MF.print (*OS);
+ OS << Banner;
+ MF.print(OS);
return false;
}
};
@@ -66,7 +64,7 @@
/// Returns a newly-created MachineFunction Printer pass. The default banner is
/// empty.
///
-FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
+FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner){
return new Printer(OS, Banner);
}
@@ -220,11 +218,6 @@
print(errs());
}
-void MachineFunction::print(std::ostream &OS) const {
- raw_os_ostream RawOS(OS);
- print(RawOS);
-}
-
void MachineFunction::print(raw_ostream &OS) const {
OS << "# Machine code for " << Fn->getName() << "():\n";
@@ -284,15 +277,16 @@
!Node->getBasicBlock()->getName().empty())
return Node->getBasicBlock()->getNameStr() + ":";
- std::ostringstream Out;
- if (ShortNames) {
- Out << Node->getNumber() << ':';
- return Out.str();
+ std::string OutStr;
+ {
+ raw_string_ostream OSS(OutStr);
+
+ if (ShortNames)
+ OSS << Node->getNumber() << ':';
+ else
+ Node->print(OSS);
}
- Node->print(Out);
-
- std::string OutStr = Out.str();
if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
// Process string output to make it nicer...
Modified: llvm/trunk/lib/CodeGen/MachineSink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSink.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineSink.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineSink.cpp Sat Aug 22 22:13:20 2009
@@ -239,15 +239,15 @@
if (MI->getParent() == SuccToSinkTo)
return false;
- DEBUG(cerr << "Sink instr " << *MI);
- DEBUG(cerr << "to block " << *SuccToSinkTo);
+ DEBUG(errs() << "Sink instr " << *MI);
+ DEBUG(errs() << "to block " << *SuccToSinkTo);
// If the block has multiple predecessors, this would introduce computation on
// a path that it doesn't already exist. We could split the critical edge,
// but for now we just punt.
// FIXME: Split critical edges if not backedges.
if (SuccToSinkTo->pred_size() > 1) {
- DEBUG(cerr << " *** PUNTING: Critical edge found\n");
+ DEBUG(errs() << " *** PUNTING: Critical edge found\n");
return false;
}
Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=79811&r1=79810&r2=79811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Sat Aug 22 22:13:20 2009
@@ -23,9 +23,6 @@
// the verifier errors.
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SetOperations.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -35,6 +32,9 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetOperations.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
More information about the llvm-commits
mailing list