Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are

now cerr, cout, and NullStream resp.

llvm-svn: 32298
This commit is contained in:
Bill Wendling 2006-12-07 01:30:32 +00:00
parent d8e7451dc3
commit f3baad3ee1
111 changed files with 1852 additions and 1687 deletions

View File

@ -53,7 +53,7 @@ int main() {
BB->getInstList().push_back(new ReturnInst(Add)); BB->getInstList().push_back(new ReturnInst(Add));
// Output the bytecode file to stdout // Output the bytecode file to stdout
WriteBytecodeToFile(M, llvm_cout); WriteBytecodeToFile(M, cout);
// Delete the module and all of its contents. // Delete the module and all of its contents.
delete M; delete M;

View File

@ -29,7 +29,6 @@
#include <bitset> #include <bitset>
#include <vector> #include <vector>
#include <functional> #include <functional>
#include <ostream>
namespace llvm { namespace llvm {
@ -174,11 +173,11 @@ public:
/// ///
/// Printing and debugging support /// Printing and debugging support
/// ///
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O) const; void print(std::ostream &O) const;
void dump() const { print(llvm_cerr); } void dump() const { print(cerr); }
public: public:
// //
@ -235,6 +234,9 @@ public:
return (I.bitvec == bitvec && return (I.bitvec == bitvec &&
I.currentWord == currentWord && I.currentBit == currentBit); I.currentWord == currentWord && I.currentBit == currentBit);
} }
bool operator!=(const iterator& I) {
return !(*this == I);
}
protected: protected:
static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); } static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); }
@ -252,7 +254,7 @@ inline void BitSetVector::print(std::ostream& O) const
O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", "); O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", ");
} }
inline llvm_ostream& operator<< (llvm_ostream& O, const BitSetVector& bset) { inline OStream& operator<< (OStream& O, const BitSetVector& bset) {
bset.print(O); bset.print(O);
return O; return O;
} }

View File

@ -43,8 +43,8 @@ namespace llvm {
/// if (!I->isLeader()) continue; // Ignore non-leader sets. /// if (!I->isLeader()) continue; // Ignore non-leader sets.
/// for (EquivalenceClasses<int>::member_iterator MI = EC.member_begin(I); /// for (EquivalenceClasses<int>::member_iterator MI = EC.member_begin(I);
/// MI != EC.member_end(); ++MI) // Loop over members in this set. /// MI != EC.member_end(); ++MI) // Loop over members in this set.
/// llvm_cerr << *MI << " "; // Print member. /// cerr << *MI << " "; // Print member.
/// llvm_cerr << "\n"; // Finish set. /// cerr << "\n"; // Finish set.
/// } /// }
/// ///
/// This example prints: /// This example prints:

View File

@ -156,7 +156,7 @@ public:
iterator end() const { return iterator(); } iterator end() const { return iterator(); }
bool empty() const { return PtrList == 0; } bool empty() const { return PtrList == 0; }
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;
@ -248,7 +248,7 @@ private:
bool aliasesCallSite(CallSite CS, AliasAnalysis &AA) const; bool aliasesCallSite(CallSite CS, AliasAnalysis &AA) const;
}; };
inline llvm_ostream& operator<<(llvm_ostream &OS, const AliasSet &AS) { inline OStream& operator<<(OStream &OS, const AliasSet &AS) {
AS.print(OS); AS.print(OS);
return OS; return OS;
} }
@ -361,7 +361,7 @@ public:
iterator begin() { return AliasSets.begin(); } iterator begin() { return AliasSets.begin(); }
iterator end() { return AliasSets.end(); } iterator end() { return AliasSets.end(); }
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;
@ -390,7 +390,7 @@ private:
AliasSet *findAliasSetForCallSite(CallSite CS); AliasSet *findAliasSetForCallSite(CallSite CS);
}; };
inline llvm_ostream& operator<<(llvm_ostream &OS, const AliasSetTracker &AST) { inline OStream& operator<<(OStream &OS, const AliasSetTracker &AST) {
AST.print(OS); AST.print(OS);
return OS; return OS;
} }

View File

@ -152,7 +152,7 @@ public:
/// ///
void initialize(Module &M); void initialize(Module &M);
void print(llvm_ostream &o, const Module *M) const { void print(OStream &o, const Module *M) const {
if (o.stream()) print(*o.stream(), M); if (o.stream()) print(*o.stream(), M);
} }
virtual void print(std::ostream &o, const Module *M) const; virtual void print(std::ostream &o, const Module *M) const;
@ -201,7 +201,7 @@ public:
/// dump - Print out this call graph node. /// dump - Print out this call graph node.
/// ///
void dump() const; void dump() const;
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;

View File

@ -378,12 +378,12 @@ public:
/// print - Print a dot graph to the specified ostream... /// print - Print a dot graph to the specified ostream...
/// ///
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O) const; void print(std::ostream &O) const;
/// dump - call print(llvm_cerr), for use from the debugger... /// dump - call print(cerr), for use from the debugger...
/// ///
void dump() const; void dump() const;

View File

@ -362,7 +362,7 @@ public:
/// ///
void forwardNode(DSNode *To, unsigned Offset); void forwardNode(DSNode *To, unsigned Offset);
void print(llvm_ostream &O, const DSGraph *G) const { void print(OStream &O, const DSGraph *G) const {
if (O.stream()) print(*O.stream(), G); if (O.stream()) print(*O.stream(), G);
} }
void print(std::ostream &O, const DSGraph *G) const; void print(std::ostream &O, const DSGraph *G) const;

View File

@ -217,7 +217,7 @@ public:
/// the mapping in the LoopInfo class. /// the mapping in the LoopInfo class.
void removeBlockFromLoop(BasicBlock *BB); void removeBlockFromLoop(BasicBlock *BB);
void print(llvm_ostream &O, unsigned Depth = 0) const { void print(OStream &O, unsigned Depth = 0) const {
if (O.stream()) print(*O.stream(), Depth); if (O.stream()) print(*O.stream(), Depth);
} }
void print(std::ostream &O, unsigned Depth = 0) const; void print(std::ostream &O, unsigned Depth = 0) const;
@ -283,7 +283,7 @@ public:
virtual bool runOnFunction(Function &F); virtual bool runOnFunction(Function &F);
virtual void releaseMemory(); virtual void releaseMemory();
void print(llvm_ostream &O, const Module* = 0) const { void print(OStream &O, const Module* = 0) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O, const Module* = 0) const; void print(std::ostream &O, const Module* = 0) const;

View File

@ -97,7 +97,7 @@ namespace llvm {
/// print - Print out the internal representation of this scalar to the /// print - Print out the internal representation of this scalar to the
/// specified stream. This should really only be used for debugging /// specified stream. This should really only be used for debugging
/// purposes. /// purposes.
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
virtual void print(std::ostream &OS) const = 0; virtual void print(std::ostream &OS) const = 0;
@ -107,7 +107,7 @@ namespace llvm {
void dump() const; void dump() const;
}; };
inline llvm_ostream &operator<<(llvm_ostream &OS, const SCEV &S) { inline OStream &operator<<(OStream &OS, const SCEV &S) {
S.print(OS); S.print(OS);
return OS; return OS;
} }
@ -128,7 +128,7 @@ namespace llvm {
virtual bool isLoopInvariant(const Loop *L) const; virtual bool isLoopInvariant(const Loop *L) const;
virtual const Type *getType() const; virtual const Type *getType() const;
virtual bool hasComputableLoopEvolution(const Loop *L) const; virtual bool hasComputableLoopEvolution(const Loop *L) const;
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
virtual void print(std::ostream &OS) const; virtual void print(std::ostream &OS) const;
@ -242,7 +242,7 @@ namespace llvm {
virtual bool runOnFunction(Function &F); virtual bool runOnFunction(Function &F);
virtual void releaseMemory(); virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const; virtual void getAnalysisUsage(AnalysisUsage &AU) const;
void print(llvm_ostream &OS, const Module* = 0) const { void print(OStream &OS, const Module* = 0) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
virtual void print(std::ostream &OS, const Module* = 0) const; virtual void print(std::ostream &OS, const Module* = 0) const;

View File

@ -18,11 +18,11 @@
#ifndef LLVM_ANALYSIS_TRACE_H #ifndef LLVM_ANALYSIS_TRACE_H
#define LLVM_ANALYSIS_TRACE_H #define LLVM_ANALYSIS_TRACE_H
#include "llvm/Support/Streams.h"
#include <vector> #include <vector>
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {
class llvm_ostream;
class BasicBlock; class BasicBlock;
class Function; class Function;
class Module; class Module;
@ -106,7 +106,7 @@ public:
/// print - Write trace to output stream. /// print - Write trace to output stream.
/// ///
void print (llvm_ostream &O) const; void print (OStream &O) const;
/// dump - Debugger convenience method; writes trace to standard error /// dump - Debugger convenience method; writes trace to standard error
/// output stream. /// output stream.

View File

@ -25,13 +25,12 @@
namespace llvm { namespace llvm {
class PrintModulePass : public ModulePass { class PrintModulePass : public ModulePass {
llvm_ostream *Out; // ostream to print on OStream *Out; // ostream to print on
bool DeleteStream; // Delete the ostream in our dtor? bool DeleteStream; // Delete the ostream in our dtor?
public: public:
PrintModulePass() : Out(&llvm_cerr), DeleteStream(false) {} PrintModulePass() : Out(&cerr), DeleteStream(false) {}
PrintModulePass(llvm_ostream *o, bool DS = false) PrintModulePass(OStream *o, bool DS = false)
: Out(o), DeleteStream(DS) { : Out(o), DeleteStream(DS) {}
}
~PrintModulePass() { ~PrintModulePass() {
if (DeleteStream) delete Out; if (DeleteStream) delete Out;
@ -49,14 +48,13 @@ public:
class PrintFunctionPass : public FunctionPass { class PrintFunctionPass : public FunctionPass {
std::string Banner; // String to print before each function std::string Banner; // String to print before each function
llvm_ostream *Out; // ostream to print on OStream *Out; // ostream to print on
bool DeleteStream; // Delete the ostream in our dtor? bool DeleteStream; // Delete the ostream in our dtor?
public: public:
PrintFunctionPass() : Banner(""), Out(&llvm_cerr), DeleteStream(false) {} PrintFunctionPass() : Banner(""), Out(&cerr), DeleteStream(false) {}
PrintFunctionPass(const std::string &B, llvm_ostream *o = &llvm_cout, PrintFunctionPass(const std::string &B, OStream *o = &cout,
bool DS = false) bool DS = false)
: Banner(B), Out(o), DeleteStream(DS) { : Banner(B), Out(o), DeleteStream(DS) {}
}
inline ~PrintFunctionPass() { inline ~PrintFunctionPass() {
if (DeleteStream) delete Out; if (DeleteStream) delete Out;

View File

@ -17,19 +17,18 @@
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/Bytecode/Writer.h" #include "llvm/Bytecode/Writer.h"
#include "llvm/Support/Streams.h"
namespace llvm { namespace llvm {
class llvm_ostream;
class WriteBytecodePass : public ModulePass { class WriteBytecodePass : public ModulePass {
llvm_ostream *Out; // ostream to print on OStream *Out; // ostream to print on
bool DeleteStream; bool DeleteStream;
bool CompressFile; bool CompressFile;
public: public:
WriteBytecodePass() WriteBytecodePass()
: Out(&llvm_cout), DeleteStream(false), CompressFile(true) {} : Out(&cout), DeleteStream(false), CompressFile(true) {}
WriteBytecodePass(llvm_ostream *o, bool DS = false, bool CF = true) WriteBytecodePass(OStream *o, bool DS = false, bool CF = true)
: Out(o), DeleteStream(DS), CompressFile(CF) {} : Out(o), DeleteStream(DS), CompressFile(CF) {}
inline ~WriteBytecodePass() { inline ~WriteBytecodePass() {

View File

@ -15,13 +15,14 @@
#ifndef LLVM_BYTECODE_WRITER_H #ifndef LLVM_BYTECODE_WRITER_H
#define LLVM_BYTECODE_WRITER_H #define LLVM_BYTECODE_WRITER_H
#include "llvm/Support/Streams.h"
namespace llvm { namespace llvm {
class llvm_ostream;
class Module; class Module;
/// WriteBytecodeToFile - Write the specified module to the specified output /// WriteBytecodeToFile - Write the specified module to the specified output
/// stream. If compress is set to true, try to use compression when writing /// stream. If compress is set to true, try to use compression when writing
/// out the file. This can never fail if M is a well-formed module. /// out the file. This can never fail if M is a well-formed module.
void WriteBytecodeToFile(const Module *M, llvm_ostream &Out, void WriteBytecodeToFile(const Module *M, OStream &Out,
bool compress = true); bool compress = true);
} // End llvm namespace } // End llvm namespace

View File

@ -62,7 +62,7 @@ namespace llvm {
}; };
std::ostream& operator<<(std::ostream& os, const LiveRange &LR); std::ostream& operator<<(std::ostream& os, const LiveRange &LR);
inline llvm_ostream& operator<<(llvm_ostream& os, const LiveRange &LR) { inline OStream& operator<<(OStream& os, const LiveRange &LR) {
if (os.stream()) *os.stream() << LR; if (os.stream()) *os.stream() << LR;
return os; return os;
} }
@ -258,9 +258,9 @@ namespace llvm {
return beginNumber() < other.beginNumber(); return beginNumber() < other.beginNumber();
} }
void print(llvm_ostream OS, const MRegisterInfo *MRI = 0) const; void print(OStream OS, const MRegisterInfo *MRI = 0) const;
void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const { void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const {
print(llvm_ostream(OS), MRI); print(OStream(OS), MRI);
} }
void dump() const; void dump() const;
@ -271,7 +271,7 @@ namespace llvm {
LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT
}; };
inline llvm_ostream &operator<<(llvm_ostream &OS, const LiveInterval &LI) { inline OStream &operator<<(OStream &OS, const LiveInterval &LI) {
LI.print(OS); LI.print(OS);
return OS; return OS;
} }

View File

@ -189,7 +189,7 @@ public:
// Debugging methods. // Debugging methods.
void dump() const; void dump() const;
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;
@ -226,7 +226,7 @@ private: // Methods used to maintain doubly linked list of blocks...
}; };
std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB); std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB);
inline llvm_ostream& operator<<(llvm_ostream &OS, const MachineBasicBlock &MBB){ inline OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB){
if (OS.stream()) *OS.stream() << MBB; if (OS.stream()) *OS.stream() << MBB;
return OS; return OS;
} }

View File

@ -49,14 +49,14 @@ public:
/// print - Implement operator<<... /// print - Implement operator<<...
/// ///
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
virtual void print(std::ostream &O) const = 0; virtual void print(std::ostream &O) const = 0;
}; };
inline llvm_ostream &operator<<(llvm_ostream &OS, inline OStream &operator<<(OStream &OS,
const MachineConstantPoolValue &V) { const MachineConstantPoolValue &V) {
V.print(OS); V.print(OS);
return OS; return OS;
} }
@ -143,7 +143,7 @@ public:
/// print - Used by the MachineFunction printer to print information about /// print - Used by the MachineFunction printer to print information about
/// constant pool objects. Implemented in MachineFunction.cpp /// constant pool objects. Implemented in MachineFunction.cpp
/// ///
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;

View File

@ -285,7 +285,7 @@ public:
IsDead = false; IsDead = false;
} }
friend llvm_ostream& operator<<(llvm_ostream& os, const MachineOperand& mop) { friend OStream& operator<<(OStream& os, const MachineOperand& mop) {
if (os.stream()) *os.stream() << mop; if (os.stream()) *os.stream() << mop;
return os; return os;
} }
@ -397,12 +397,12 @@ public:
// //
// Debugging support // Debugging support
// //
void print(llvm_ostream &OS, const TargetMachine *TM) const { void print(OStream &OS, const TargetMachine *TM) const {
if (OS.stream()) print(*OS.stream(), TM); if (OS.stream()) print(*OS.stream(), TM);
} }
void print(std::ostream &OS, const TargetMachine *TM) const; void print(std::ostream &OS, const TargetMachine *TM) const;
void dump() const; void dump() const;
friend llvm_ostream& operator<<(llvm_ostream& os, const MachineInstr& minstr){ friend OStream& operator<<(OStream& os, const MachineInstr& minstr){
if (os.stream()) *os.stream() << minstr; if (os.stream()) *os.stream() << minstr;
return os; return os;
} }

View File

@ -70,7 +70,7 @@ public:
void dump(int indent=0) const; void dump(int indent=0) const;
// Debugging support // Debugging support
void print(llvm_ostream &os) const { void print(OStream &os) const {
if (os.stream()) print(*os.stream()); if (os.stream()) print(*os.stream());
} }
virtual void print(std::ostream &os) const = 0; virtual void print(std::ostream &os) const = 0;
@ -96,8 +96,8 @@ protected:
}; };
// ostream << operator for SchedGraphNode class // ostream << operator for SchedGraphNode class
inline llvm_ostream &operator<<(llvm_ostream &os, inline OStream &operator<<(OStream &os,
const SchedGraphNodeCommon &node) { const SchedGraphNodeCommon &node) {
node.print(os); node.print(os);
return os; return os;
} }
@ -188,7 +188,7 @@ public:
public: public:
// Debugging support // Debugging support
void print(llvm_ostream &os) const { void print(OStream &os) const {
if (os.stream()) print(*os.stream()); if (os.stream()) print(*os.stream());
} }
void print(std::ostream &os) const; void print(std::ostream &os) const;
@ -200,7 +200,7 @@ private:
}; };
// ostream << operator for SchedGraphNode class // ostream << operator for SchedGraphNode class
inline llvm_ostream &operator<<(llvm_ostream &os, const SchedGraphEdge &edge) { inline OStream &operator<<(OStream &os, const SchedGraphEdge &edge) {
edge.print(os); edge.print(os);
return os; return os;
} }

View File

@ -295,12 +295,12 @@ public:
/// @{ /// @{
public: public:
/// Print the module to an output stream /// Print the module to an output stream
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream(), 0); if (OS.stream()) print(*OS.stream(), 0);
} }
void print(std::ostream &OS) const { print(OS, 0); } void print(std::ostream &OS) const { print(OS, 0); }
/// Print the module to an output stream with AssemblyAnnotationWriter. /// Print the module to an output stream with AssemblyAnnotationWriter.
void print(llvm_ostream &OS, AssemblyAnnotationWriter *AAW) const { void print(OStream &OS, AssemblyAnnotationWriter *AAW) const {
if (OS.stream()) print(*OS.stream(), AAW); if (OS.stream()) print(*OS.stream(), AAW);
} }
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const; void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;

View File

@ -101,7 +101,7 @@ public:
/// provide the Module* in case the analysis doesn't need it it can just be /// provide the Module* in case the analysis doesn't need it it can just be
/// ignored. /// ignored.
/// ///
void print(llvm_ostream &O, const Module *M) const { void print(OStream &O, const Module *M) const {
if (O.stream()) print(*O.stream(), M); if (O.stream()) print(*O.stream(), M);
} }
virtual void print(std::ostream &O, const Module *M) const; virtual void print(std::ostream &O, const Module *M) const;

View File

@ -245,13 +245,13 @@ private:
struct foo { struct foo {
void ext() const; void ext() const;
/* static bool classof(const bar *X) { /* static bool classof(const bar *X) {
llvm_cerr << "Classof: " << X << "\n"; cerr << "Classof: " << X << "\n";
return true; return true;
}*/ }*/
}; };
template <> inline bool isa_impl<foo,bar>(const bar &Val) { template <> inline bool isa_impl<foo,bar>(const bar &Val) {
llvm_cerr << "Classof: " << &Val << "\n"; cerr << "Classof: " << &Val << "\n";
return true; return true;
} }

View File

@ -141,7 +141,7 @@ class ConstantRange {
/// print - Print out the bounds to a stream... /// print - Print out the bounds to a stream...
/// ///
void print(llvm_ostream &OS) const { void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream()); if (OS.stream()) print(*OS.stream());
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;

View File

@ -65,10 +65,10 @@ bool isCurrentDebugType(const char *Type);
/// places the std::c* I/O streams into one .cpp file and relieves the whole /// places the std::c* I/O streams into one .cpp file and relieves the whole
/// program from having to have hundreds of static c'tor/d'tors for them. /// program from having to have hundreds of static c'tor/d'tors for them.
/// ///
llvm_ostream getErrorOutputStream(const char *DebugType); OStream getErrorOutputStream(const char *DebugType);
#ifdef NDEBUG #ifdef NDEBUG
#define DOUT llvm_ostream() #define DOUT NullStream
#else #else
#define DOUT getErrorOutputStream(DEBUG_TYPE) #define DOUT getErrorOutputStream(DEBUG_TYPE)
#endif #endif

View File

@ -247,16 +247,16 @@ sys::Path WriteGraph(const GraphType &G,
std::string ErrMsg; std::string ErrMsg;
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
if (Filename.isEmpty()) { if (Filename.isEmpty()) {
llvm_cerr << "Error: " << ErrMsg << "\n"; cerr << "Error: " << ErrMsg << "\n";
return Filename; return Filename;
} }
Filename.appendComponent(Name + ".dot"); Filename.appendComponent(Name + ".dot");
if (Filename.makeUnique(true,&ErrMsg)) { if (Filename.makeUnique(true,&ErrMsg)) {
llvm_cerr << "Error: " << ErrMsg << "\n"; cerr << "Error: " << ErrMsg << "\n";
return sys::Path(); return sys::Path();
} }
llvm_cerr << "Writing '" << Filename << "'... "; cerr << "Writing '" << Filename << "'... ";
std::ofstream O(Filename.c_str()); std::ofstream O(Filename.c_str());
@ -275,12 +275,12 @@ sys::Path WriteGraph(const GraphType &G,
// Output the end of the graph // Output the end of the graph
W.writeFooter(); W.writeFooter();
llvm_cerr << " done. \n"; cerr << " done. \n";
O.close(); O.close();
} else { } else {
llvm_cerr << "error opening file for writing!\n"; cerr << "error opening file for writing!\n";
Filename.clear(); Filename.clear();
} }

View File

@ -65,8 +65,8 @@ public:
virtual void passRegistered(const PassInfo *P) { virtual void passRegistered(const PassInfo *P) {
if (ignorablePass(P) || !Opt) return; if (ignorablePass(P) || !Opt) return;
if (findOption(P->getPassArgument()) != getNumOptions()) { if (findOption(P->getPassArgument()) != getNumOptions()) {
llvm_cerr << "Two passes with the same argument (-" cerr << "Two passes with the same argument (-"
<< P->getPassArgument() << ") attempted to be registered!\n"; << P->getPassArgument() << ") attempted to be registered!\n";
abort(); abort();
} }
addLiteralOption(P->getPassArgument(), P, P->getPassName()); addLiteralOption(P->getPassArgument(), P, P->getPassName());

View File

@ -7,48 +7,64 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements a wrapper for the std::cout and std::cerr I/O streams. // This file implements a wrapper for the STL I/O streams. It prevents the need
// It prevents the need to include <iostream> to each file just to get I/O. // to include <iostream> in a file just to get I/O.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_STREAMS_H #ifndef LLVM_SUPPORT_STREAMS_H
#define LLVM_SUPPORT_STREAMS_H #define LLVM_SUPPORT_STREAMS_H
#include <ostream> // Doesn't have static d'tors!! #include <sstream>
namespace llvm { namespace llvm {
/// llvm_ostream - Acts like an ostream. It's a wrapper for the std::cerr and /// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr,
/// std::cout ostreams. However, it doesn't require #including <iostream> in /// std::cout, std::cin, etc. streams. However, it doesn't require #including
/// every file, which increases static c'tors & d'tors in the object code. /// <iostream> in every file (doing so increases static c'tors & d'tors in the
/// object code).
/// ///
class llvm_ostream { template <typename StreamTy>
std::ostream* Stream; class BaseStream {
StreamTy *Stream;
public: public:
llvm_ostream() : Stream(0) {} BaseStream() : Stream(0) {}
llvm_ostream(std::ostream &OStream) : Stream(&OStream) {} BaseStream(StreamTy &S) : Stream(&S) {}
BaseStream(StreamTy *S) : Stream(S) {}
std::ostream* stream() const { return Stream; } StreamTy *stream() const { return Stream; }
inline llvm_ostream &operator << (std::ostream& (*Func)(std::ostream&)) { inline BaseStream &operator << (StreamTy &(*Func)(StreamTy&)) {
if (Stream) *Stream << Func; if (Stream) *Stream << Func;
return *this; return *this;
} }
template <typename Ty> template <typename Ty>
llvm_ostream &operator << (const Ty &Thing) { BaseStream &operator << (const Ty &Thing) {
if (Stream) *Stream << Thing; if (Stream) *Stream << Thing;
return *this; return *this;
} }
bool operator == (const std::ostream &OS) { return &OS == Stream; } template <typename Ty>
bool operator == (const llvm_ostream &OS) { return OS.Stream == Stream; } BaseStream &operator >> (const Ty &Thing) {
if (Stream) *Stream >> Thing;
return *this;
}
bool operator == (const StreamTy &S) { return &S == Stream; }
bool operator != (const StreamTy &S) { return !(*this == S); }
bool operator == (const BaseStream &S) { return S.Stream == Stream; }
bool operator != (const BaseStream &S) { return !(*this == S); }
}; };
extern llvm_ostream llvm_null; typedef BaseStream<std::ostream> OStream;
extern llvm_ostream llvm_cout; typedef BaseStream<std::istream> IStream;
extern llvm_ostream llvm_cerr; typedef BaseStream<std::stringstream> StringStream;
extern OStream NullStream;
extern OStream cout;
extern OStream cerr;
extern IStream cin;
} // End llvm namespace } // End llvm namespace

View File

@ -136,7 +136,7 @@ protected:
/// ///
mutable std::vector<AbstractTypeUser *> AbstractTypeUsers; mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
public: public:
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O) const; void print(std::ostream &O) const;

View File

@ -75,7 +75,7 @@ public:
/// print - Implement operator<< on Value... /// print - Implement operator<< on Value...
/// ///
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
virtual void print(std::ostream &O) const = 0; virtual void print(std::ostream &O) const = 0;

View File

@ -39,37 +39,33 @@ namespace {
} }
void printLine(const char *Desc, unsigned Val, unsigned Sum) { void printLine(const char *Desc, unsigned Val, unsigned Sum) {
llvm_cerr << " " << Val << " " << Desc << " responses (" cerr << " " << Val << " " << Desc << " responses ("
<< Val*100/Sum << "%)\n"; << Val*100/Sum << "%)\n";
} }
~AliasAnalysisCounter() { ~AliasAnalysisCounter() {
unsigned AASum = No+May+Must; unsigned AASum = No+May+Must;
unsigned MRSum = NoMR+JustRef+JustMod+MR; unsigned MRSum = NoMR+JustRef+JustMod+MR;
if (AASum + MRSum) { // Print a report if any counted queries occurred... if (AASum + MRSum) { // Print a report if any counted queries occurred...
llvm_cerr cerr << "\n===== Alias Analysis Counter Report =====\n"
<< "\n===== Alias Analysis Counter Report =====\n" << " Analysis counted: " << Name << "\n"
<< " Analysis counted: " << Name << "\n" << " " << AASum << " Total Alias Queries Performed\n";
<< " " << AASum << " Total Alias Queries Performed\n";
if (AASum) { if (AASum) {
printLine("no alias", No, AASum); printLine("no alias", No, AASum);
printLine("may alias", May, AASum); printLine("may alias", May, AASum);
printLine("must alias", Must, AASum); printLine("must alias", Must, AASum);
llvm_cerr cerr << " Alias Analysis Counter Summary: " << No*100/AASum << "%/"
<< " Alias Analysis Counter Summary: " << No*100/AASum << "%/" << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n";
<< May*100/AASum << "%/" << Must*100/AASum<<"%\n\n";
} }
llvm_cerr cerr << " " << MRSum << " Total Mod/Ref Queries Performed\n";
<< " " << MRSum << " Total Mod/Ref Queries Performed\n";
if (MRSum) { if (MRSum) {
printLine("no mod/ref", NoMR, MRSum); printLine("no mod/ref", NoMR, MRSum);
printLine("ref", JustRef, MRSum); printLine("ref", JustRef, MRSum);
printLine("mod", JustMod, MRSum); printLine("mod", JustMod, MRSum);
printLine("mod/ref", MR, MRSum); printLine("mod/ref", MR, MRSum);
llvm_cerr cerr << " Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum<< "%/"
<< " Mod/Ref Analysis Counter Summary: " << NoMR*100/MRSum<< "%/" << JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/"
<< JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/" << MR*100/MRSum <<"%\n\n";
<< MR*100/MRSum <<"%\n\n";
} }
} }
} }
@ -133,10 +129,10 @@ AliasAnalysisCounter::alias(const Value *V1, unsigned V1Size,
} }
if (PrintAll || (PrintAllFailures && R == MayAlias)) { if (PrintAll || (PrintAllFailures && R == MayAlias)) {
llvm_cerr << AliasString << ":\t"; cerr << AliasString << ":\t";
llvm_cerr << "[" << V1Size << "B] "; cerr << "[" << V1Size << "B] ";
WriteAsOperand(std::cerr, V1, true, M) << ", "; WriteAsOperand(std::cerr, V1, true, M) << ", ";
llvm_cerr << "[" << V2Size << "B] "; cerr << "[" << V2Size << "B] ";
WriteAsOperand(std::cerr, V2, true, M) << "\n"; WriteAsOperand(std::cerr, V2, true, M) << "\n";
} }
@ -157,10 +153,10 @@ AliasAnalysisCounter::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
} }
if (PrintAll || (PrintAllFailures && R == ModRef)) { if (PrintAll || (PrintAllFailures && R == ModRef)) {
llvm_cerr << MRString << ": Ptr: "; cerr << MRString << ": Ptr: ";
llvm_cerr << "[" << Size << "B] "; cerr << "[" << Size << "B] ";
WriteAsOperand(std::cerr, P, true, M); WriteAsOperand(std::cerr, P, true, M);
llvm_cerr << "\t<->" << *CS.getInstruction(); cerr << "\t<->" << *CS.getInstruction();
} }
return R; return R;
} }

View File

@ -79,7 +79,7 @@ FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
static inline void PrintResults(const char *Msg, bool P, Value *V1, Value *V2, static inline void PrintResults(const char *Msg, bool P, Value *V1, Value *V2,
Module *M) { Module *M) {
if (P) { if (P) {
llvm_cerr << " " << Msg << ":\t"; cerr << " " << Msg << ":\t";
WriteAsOperand(std::cerr, V1, true, M) << ", "; WriteAsOperand(std::cerr, V1, true, M) << ", ";
WriteAsOperand(std::cerr, V2, true, M) << "\n"; WriteAsOperand(std::cerr, V2, true, M) << "\n";
} }
@ -89,9 +89,9 @@ static inline void
PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr,
Module *M) { Module *M) {
if (P) { if (P) {
llvm_cerr << " " << Msg << ": Ptr: "; cerr << " " << Msg << ": Ptr: ";
WriteAsOperand(std::cerr, Ptr, true, M); WriteAsOperand(std::cerr, Ptr, true, M);
llvm_cerr << "\t<->" << *I; cerr << "\t<->" << *I;
} }
} }
@ -125,8 +125,8 @@ bool AAEval::runOnFunction(Function &F) {
if (PrintNoAlias || PrintMayAlias || PrintMustAlias || if (PrintNoAlias || PrintMayAlias || PrintMustAlias ||
PrintNoModRef || PrintMod || PrintRef || PrintModRef) PrintNoModRef || PrintMod || PrintRef || PrintModRef)
llvm_cerr << "Function: " << F.getName() << ": " << Pointers.size() cerr << "Function: " << F.getName() << ": " << Pointers.size()
<< " pointers, " << CallSites.size() << " call sites\n"; << " pointers, " << CallSites.size() << " call sites\n";
// iterate over the worklist, and run the full (n^2)/2 disambiguations // iterate over the worklist, and run the full (n^2)/2 disambiguations
for (std::set<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end(); for (std::set<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
@ -151,7 +151,7 @@ bool AAEval::runOnFunction(Function &F) {
PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent()); PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent());
++MustAlias; break; ++MustAlias; break;
default: default:
llvm_cerr << "Unknown alias query result!\n"; cerr << "Unknown alias query result!\n";
} }
} }
} }
@ -181,7 +181,7 @@ bool AAEval::runOnFunction(Function &F) {
PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent());
++ModRef; break; ++ModRef; break;
default: default:
llvm_cerr << "Unknown alias query result!\n"; cerr << "Unknown alias query result!\n";
} }
} }
} }
@ -190,45 +190,45 @@ bool AAEval::runOnFunction(Function &F) {
} }
static void PrintPercent(unsigned Num, unsigned Sum) { static void PrintPercent(unsigned Num, unsigned Sum) {
llvm_cerr << "(" << Num*100ULL/Sum << "." cerr << "(" << Num*100ULL/Sum << "."
<< ((Num*1000ULL/Sum) % 10) << "%)\n"; << ((Num*1000ULL/Sum) % 10) << "%)\n";
} }
bool AAEval::doFinalization(Module &M) { bool AAEval::doFinalization(Module &M) {
unsigned AliasSum = NoAlias + MayAlias + MustAlias; unsigned AliasSum = NoAlias + MayAlias + MustAlias;
llvm_cerr << "===== Alias Analysis Evaluator Report =====\n"; cerr << "===== Alias Analysis Evaluator Report =====\n";
if (AliasSum == 0) { if (AliasSum == 0) {
llvm_cerr << " Alias Analysis Evaluator Summary: No pointers!\n"; cerr << " Alias Analysis Evaluator Summary: No pointers!\n";
} else { } else {
llvm_cerr << " " << AliasSum << " Total Alias Queries Performed\n"; cerr << " " << AliasSum << " Total Alias Queries Performed\n";
llvm_cerr << " " << NoAlias << " no alias responses "; cerr << " " << NoAlias << " no alias responses ";
PrintPercent(NoAlias, AliasSum); PrintPercent(NoAlias, AliasSum);
llvm_cerr << " " << MayAlias << " may alias responses "; cerr << " " << MayAlias << " may alias responses ";
PrintPercent(MayAlias, AliasSum); PrintPercent(MayAlias, AliasSum);
llvm_cerr << " " << MustAlias << " must alias responses "; cerr << " " << MustAlias << " must alias responses ";
PrintPercent(MustAlias, AliasSum); PrintPercent(MustAlias, AliasSum);
llvm_cerr << " Alias Analysis Evaluator Pointer Alias Summary: " cerr << " Alias Analysis Evaluator Pointer Alias Summary: "
<< NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/" << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/"
<< MustAlias*100/AliasSum << "%\n"; << MustAlias*100/AliasSum << "%\n";
} }
// Display the summary for mod/ref analysis // Display the summary for mod/ref analysis
unsigned ModRefSum = NoModRef + Mod + Ref + ModRef; unsigned ModRefSum = NoModRef + Mod + Ref + ModRef;
if (ModRefSum == 0) { if (ModRefSum == 0) {
llvm_cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n"; cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
} else { } else {
llvm_cerr << " " << ModRefSum << " Total ModRef Queries Performed\n"; cerr << " " << ModRefSum << " Total ModRef Queries Performed\n";
llvm_cerr << " " << NoModRef << " no mod/ref responses "; cerr << " " << NoModRef << " no mod/ref responses ";
PrintPercent(NoModRef, ModRefSum); PrintPercent(NoModRef, ModRefSum);
llvm_cerr << " " << Mod << " mod responses "; cerr << " " << Mod << " mod responses ";
PrintPercent(Mod, ModRefSum); PrintPercent(Mod, ModRefSum);
llvm_cerr << " " << Ref << " ref responses "; cerr << " " << Ref << " ref responses ";
PrintPercent(Ref, ModRefSum); PrintPercent(Ref, ModRefSum);
llvm_cerr << " " << ModRef << " mod & ref responses "; cerr << " " << ModRef << " mod & ref responses ";
PrintPercent(ModRef, ModRefSum); PrintPercent(ModRef, ModRefSum);
llvm_cerr << " Alias Analysis Evaluator Mod/Ref Summary: " cerr << " Alias Analysis Evaluator Mod/Ref Summary: "
<< NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/" << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/"
<< Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n"; << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n";
} }
return false; return false;

View File

@ -543,8 +543,8 @@ void AliasSetTracker::print(std::ostream &OS) const {
OS << "\n"; OS << "\n";
} }
void AliasSet::dump() const { print (llvm_cerr); } void AliasSet::dump() const { print (cerr); }
void AliasSetTracker::dump() const { print(llvm_cerr); } void AliasSetTracker::dump() const { print(cerr); }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// AliasSetPrinter Pass // AliasSetPrinter Pass
@ -564,7 +564,7 @@ namespace {
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
Tracker->add(&*I); Tracker->add(&*I);
Tracker->print(llvm_cerr); Tracker->print(cerr);
delete Tracker; delete Tracker;
return false; return false;
} }

View File

@ -745,8 +745,8 @@ BasicAliasAnalysis::CheckGEPInstructions(
assert(Offset1<Offset2 && "There is at least one different constant here!"); assert(Offset1<Offset2 && "There is at least one different constant here!");
if ((uint64_t)(Offset2-Offset1) >= SizeMax) { if ((uint64_t)(Offset2-Offset1) >= SizeMax) {
//llvm_cerr << "Determined that these two GEP's don't alias [" //cerr << "Determined that these two GEP's don't alias ["
// << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2;
return NoAlias; return NoAlias;
} }
} }

View File

@ -92,14 +92,14 @@ namespace {
struct CFGPrinter : public FunctionPass { struct CFGPrinter : public FunctionPass {
virtual bool runOnFunction(Function &F) { virtual bool runOnFunction(Function &F) {
std::string Filename = "cfg." + F.getName() + ".dot"; std::string Filename = "cfg." + F.getName() + ".dot";
llvm_cerr << "Writing '" << Filename << "'..."; cerr << "Writing '" << Filename << "'...";
std::ofstream File(Filename.c_str()); std::ofstream File(Filename.c_str());
if (File.good()) if (File.good())
WriteGraph(File, (const Function*)&F); WriteGraph(File, (const Function*)&F);
else else
llvm_cerr << " error opening file for writing!"; cerr << " error opening file for writing!";
llvm_cerr << "\n"; cerr << "\n";
return false; return false;
} }

View File

@ -370,5 +370,5 @@ void ConstantRange::print(std::ostream &OS) const {
/// dump - Allow printing from a debugger easily... /// dump - Allow printing from a debugger easily...
/// ///
void ConstantRange::dump() const { void ConstantRange::dump() const {
print(llvm_cerr); print(cerr);
} }

View File

@ -501,7 +501,7 @@ DSGraph &BUDataStructures::CreateGraphForExternalFunction(const Function &Fn) {
DSG->getNodeForValue(F->arg_begin()).mergeWith(N); DSG->getNodeForValue(F->arg_begin()).mergeWith(N);
} else { } else {
llvm_cerr << "Unrecognized external function: " << F->getName() << "\n"; cerr << "Unrecognized external function: " << F->getName() << "\n";
abort(); abort();
} }
@ -588,21 +588,21 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
++NumBUInlines; ++NumBUInlines;
} else { } else {
if (!Printed) if (!Printed)
llvm_cerr << "In Fns: " << Graph.getFunctionNames() << "\n"; cerr << "In Fns: " << Graph.getFunctionNames() << "\n";
llvm_cerr << " calls " << CalledFuncs.size() cerr << " calls " << CalledFuncs.size()
<< " fns from site: " << CS.getCallSite().getInstruction() << " fns from site: " << CS.getCallSite().getInstruction()
<< " " << *CS.getCallSite().getInstruction(); << " " << *CS.getCallSite().getInstruction();
llvm_cerr << " Fns ="; cerr << " Fns =";
unsigned NumPrinted = 0; unsigned NumPrinted = 0;
for (std::vector<Function*>::iterator I = CalledFuncs.begin(), for (std::vector<Function*>::iterator I = CalledFuncs.begin(),
E = CalledFuncs.end(); I != E; ++I) { E = CalledFuncs.end(); I != E; ++I) {
if (NumPrinted++ < 8) llvm_cerr << " " << (*I)->getName(); if (NumPrinted++ < 8) cerr << " " << (*I)->getName();
// Add the call edges to the call graph. // Add the call edges to the call graph.
ActualCallees.insert(std::make_pair(TheCall, *I)); ActualCallees.insert(std::make_pair(TheCall, *I));
} }
llvm_cerr << "\n"; cerr << "\n";
// See if we already computed a graph for this set of callees. // See if we already computed a graph for this set of callees.
std::sort(CalledFuncs.begin(), CalledFuncs.end()); std::sort(CalledFuncs.begin(), CalledFuncs.end());
@ -645,7 +645,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
// Clean up the final graph! // Clean up the final graph!
GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
} else { } else {
llvm_cerr << "***\n*** RECYCLED GRAPH ***\n***\n"; cerr << "***\n*** RECYCLED GRAPH ***\n***\n";
} }
GI = IndCallGraph.first; GI = IndCallGraph.first;
@ -685,7 +685,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
E = MainSM.global_end(); I != E; ++I) E = MainSM.global_end(); I != E; ++I)
RC.getClonedNH(MainSM[*I]); RC.getClonedNH(MainSM[*I]);
//Graph.writeGraphToFile(llvm_cerr, "bu_" + F.getName()); //Graph.writeGraphToFile(cerr, "bu_" + F.getName());
} }
static const Function *getFnForValue(const Value *V) { static const Function *getFnForValue(const Value *V) {
@ -746,8 +746,8 @@ void BUDataStructures::copyValue(Value *From, Value *To) {
return; return;
} }
llvm_cerr << *From; cerr << *From;
llvm_cerr << *To; cerr << *To;
assert(0 && "Do not know how to copy this yet!"); assert(0 && "Do not know how to copy this yet!");
abort(); abort();
} }

View File

@ -17,15 +17,15 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Analysis/DataStructure/CallTargets.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Analysis/DataStructure/DataStructure.h"
#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Analysis/DataStructure/DSGraph.h"
#include "llvm/Analysis/DataStructure/CallTargets.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include <ostream>
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include <ostream>
using namespace llvm; using namespace llvm;
namespace { namespace {
@ -58,11 +58,11 @@ void CallTargetFinder::findIndTargets(Module &M)
} }
if (N->isComplete() && !IndMap[cs].size()) { if (N->isComplete() && !IndMap[cs].size()) {
++CompleteEmpty; ++CompleteEmpty;
llvm_cerr << "Call site empty: '" cerr << "Call site empty: '"
<< cs.getInstruction()->getName() << cs.getInstruction()->getName()
<< "' In '" << "' In '"
<< cs.getInstruction()->getParent()->getParent()->getName() << cs.getInstruction()->getParent()->getParent()->getName()
<< "'\n"; << "'\n";
} }
} else { } else {
++DirCall; ++DirCall;

View File

@ -25,7 +25,6 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/Timer.h" #include "llvm/Support/Timer.h"
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
@ -1263,7 +1262,7 @@ DSGraph::~DSGraph() {
} }
// dump - Allow inspection of graph in a debugger. // dump - Allow inspection of graph in a debugger.
void DSGraph::dump() const { print(llvm_cerr); } void DSGraph::dump() const { print(cerr); }
/// remapLinks - Change all of the Links in the current node according to the /// remapLinks - Change all of the Links in the current node according to the

View File

@ -92,18 +92,18 @@ void DSGraphStats::countCallees(const Function& F) {
totalNumCallees += Callees.size(); totalNumCallees += Callees.size();
++numIndirectCalls; ++numIndirectCalls;
} else } else
llvm_cerr << "WARNING: No callee in Function '" << F.getName() cerr << "WARNING: No callee in Function '" << F.getName()
<< "' at call: \n" << "' at call: \n"
<< *I->getCallSite().getInstruction(); << *I->getCallSite().getInstruction();
} }
TotalNumCallees += totalNumCallees; TotalNumCallees += totalNumCallees;
NumIndirectCalls += numIndirectCalls; NumIndirectCalls += numIndirectCalls;
if (numIndirectCalls) if (numIndirectCalls)
llvm_cout << " In function " << F.getName() << ": " cout << " In function " << F.getName() << ": "
<< (totalNumCallees / (double) numIndirectCalls) << (totalNumCallees / (double) numIndirectCalls)
<< " average callees per indirect call\n"; << " average callees per indirect call\n";
} }
DSNode *DSGraphStats::getNodeForValue(Value *V) { DSNode *DSGraphStats::getNodeForValue(Value *V) {

View File

@ -90,7 +90,7 @@ bool EquivClassGraphs::runOnModule(Module &M) {
if (MainFunc && !MainFunc->isExternal()) { if (MainFunc && !MainFunc->isExternal()) {
processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap);
} else { } else {
llvm_cerr << "Fold Graphs: No 'main' function found!\n"; cerr << "Fold Graphs: No 'main' function found!\n";
} }
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)

View File

@ -84,8 +84,8 @@ FunctionPass *llvm::createDataStructureGraphCheckerPass() {
DSGC::DSGC() { DSGC::DSGC() {
if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() && if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() &&
CheckFlags.empty() && AbortIfMerged.empty()) { CheckFlags.empty() && AbortIfMerged.empty()) {
llvm_cerr << "The -datastructure-gc is useless if you don't specify any" cerr << "The -datastructure-gc is useless if you don't specify any"
" -dsgc-* options. See the -help-hidden output for a list.\n"; << " -dsgc-* options. See the -help-hidden output for a list.\n";
abort(); abort();
} }
} }
@ -123,8 +123,8 @@ void DSGC::verify(const DSGraph &G) {
for (DSGraph::node_const_iterator I = G.node_begin(), E = G.node_end(); for (DSGraph::node_const_iterator I = G.node_begin(), E = G.node_end();
I != E; ++I) I != E; ++I)
if (I->isNodeCompletelyFolded()) { if (I->isNodeCompletelyFolded()) {
llvm_cerr << "Node is collapsed: "; cerr << "Node is collapsed: ";
I->print(llvm_cerr, &G); I->print(cerr, &G);
abort(); abort();
} }
} }
@ -142,8 +142,8 @@ void DSGC::verify(const DSGraph &G) {
E = CheckFlags.end(); I != E; ++I) { E = CheckFlags.end(); I != E; ++I) {
std::string::size_type ColonPos = I->rfind(':'); std::string::size_type ColonPos = I->rfind(':');
if (ColonPos == std::string::npos) { if (ColonPos == std::string::npos) {
llvm_cerr << "Error: '" << *I cerr << "Error: '" << *I
<< "' is an invalid value for the --dsgc-check-flags option!\n"; << "' is an invalid value for the --dsgc-check-flags option!\n";
abort(); abort();
} }
@ -158,7 +158,7 @@ void DSGC::verify(const DSGraph &G) {
case 'M': Flags |= DSNode::Modified; break; case 'M': Flags |= DSNode::Modified; break;
case 'R': Flags |= DSNode::Read; break; case 'R': Flags |= DSNode::Read; break;
case 'A': Flags |= DSNode::Array; break; case 'A': Flags |= DSNode::Array; break;
default: llvm_cerr << "Invalid DSNode flag!\n"; abort(); default: cerr << "Invalid DSNode flag!\n"; abort();
} }
CheckFlagsM[std::string(I->begin(), I->begin()+ColonPos)] = Flags; CheckFlagsM[std::string(I->begin(), I->begin()+ColonPos)] = Flags;
} }
@ -176,25 +176,25 @@ void DSGC::verify(const DSGraph &G) {
// Verify it is not collapsed if it is not supposed to be... // Verify it is not collapsed if it is not supposed to be...
if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) { if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) {
llvm_cerr << "Node for value '%" << Name << "' is collapsed: "; cerr << "Node for value '%" << Name << "' is collapsed: ";
N->print(llvm_cerr, &G); N->print(cerr, &G);
abort(); abort();
} }
if (CheckFlagsM.count(Name) && CheckFlagsM[Name] != N->getNodeFlags()) { if (CheckFlagsM.count(Name) && CheckFlagsM[Name] != N->getNodeFlags()) {
llvm_cerr << "Node flags are not as expected for node: " << Name cerr << "Node flags are not as expected for node: " << Name
<< " (" << CheckFlagsM[Name] << ":" <<N->getNodeFlags() << " (" << CheckFlagsM[Name] << ":" <<N->getNodeFlags()
<< ")\n"; << ")\n";
N->print(llvm_cerr, &G); N->print(cerr, &G);
abort(); abort();
} }
// Verify that it is not merged if it is not supposed to be... // Verify that it is not merged if it is not supposed to be...
if (AbortIfMergedS.count(Name)) { if (AbortIfMergedS.count(Name)) {
if (AbortIfMergedNodes.count(N)) { if (AbortIfMergedNodes.count(N)) {
llvm_cerr << "Nodes for values '%" << Name << "' and '%" cerr << "Nodes for values '%" << Name << "' and '%"
<< AbortIfMergedNodes[N] << "' is merged: "; << AbortIfMergedNodes[N] << "' is merged: ";
N->print(llvm_cerr, &G); N->print(cerr, &G);
abort(); abort();
} }
AbortIfMergedNodes[N] = Name; AbortIfMergedNodes[N] = Name;

View File

@ -434,7 +434,7 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) {
// Variable index into a node. We must merge all of the elements of the // Variable index into a node. We must merge all of the elements of the
// sequential type here. // sequential type here.
if (isa<PointerType>(STy)) if (isa<PointerType>(STy))
llvm_cerr << "Pointer indexing not handled yet!\n"; cerr << "Pointer indexing not handled yet!\n";
else { else {
const ArrayType *ATy = cast<ArrayType>(STy); const ArrayType *ATy = cast<ArrayType>(STy);
unsigned ElSize = TD.getTypeSize(CurTy); unsigned ElSize = TD.getTypeSize(CurTy);
@ -1061,7 +1061,7 @@ void GraphBuilder::visitCallSite(CallSite CS) {
if (DisableDirectCallOpt || !isa<Function>(Callee)) { if (DisableDirectCallOpt || !isa<Function>(Callee)) {
CalleeNode = getValueDest(*Callee).getNode(); CalleeNode = getValueDest(*Callee).getNode();
if (CalleeNode == 0) { if (CalleeNode == 0) {
llvm_cerr << "WARNING: Program is calling through a null pointer?\n"<< *I; cerr << "WARNING: Program is calling through a null pointer?\n"<< *I;
return; // Calling a null pointer? return; // Calling a null pointer?
} }
} }

View File

@ -37,7 +37,7 @@ namespace {
Statistic NumFoldedNodes ("dsa", "Number of folded nodes (in final graph)"); Statistic NumFoldedNodes ("dsa", "Number of folded nodes (in final graph)");
} }
void DSNode::dump() const { print(llvm_cerr, 0); } void DSNode::dump() const { print(cerr, 0); }
static std::string getCaption(const DSNode *N, const DSGraph *G) { static std::string getCaption(const DSNode *N, const DSGraph *G) {
std::stringstream OS; std::stringstream OS;

View File

@ -53,7 +53,7 @@ namespace {
} }
// print - Implement the Pass::print method... // print - Implement the Pass::print method...
void print(llvm_ostream O, const Module *M) const { void print(OStream O, const Module *M) const {
if (O.stream()) print(*O.stream(), M); if (O.stream()) print(*O.stream(), M);
} }
void print(std::ostream &O, const Module *M) const { void print(std::ostream &O, const Module *M) const {

View File

@ -533,7 +533,7 @@ Andersens::Node *Andersens::getNodeForConstantPointer(Constant *C) {
case Instruction::BitCast: case Instruction::BitCast:
return getNodeForConstantPointer(CE->getOperand(0)); return getNodeForConstantPointer(CE->getOperand(0));
default: default:
llvm_cerr << "Constant Expr not yet handled: " << *CE << "\n"; cerr << "Constant Expr not yet handled: " << *CE << "\n";
assert(0); assert(0);
} }
} else { } else {
@ -560,7 +560,7 @@ Andersens::Node *Andersens::getNodeForConstantPointerTarget(Constant *C) {
case Instruction::BitCast: case Instruction::BitCast:
return getNodeForConstantPointerTarget(CE->getOperand(0)); return getNodeForConstantPointerTarget(CE->getOperand(0));
default: default:
llvm_cerr << "Constant Expr not yet handled: " << *CE << "\n"; cerr << "Constant Expr not yet handled: " << *CE << "\n";
assert(0); assert(0);
} }
} else { } else {
@ -786,7 +786,7 @@ void Andersens::visitInstruction(Instruction &I) {
return; return;
default: default:
// Is this something we aren't handling yet? // Is this something we aren't handling yet?
llvm_cerr << "Unknown instruction: " << I; cerr << "Unknown instruction: " << I;
abort(); abort();
} }
} }
@ -1104,13 +1104,13 @@ void Andersens::SolveConstraints() {
void Andersens::PrintNode(Node *N) { void Andersens::PrintNode(Node *N) {
if (N == &GraphNodes[UniversalSet]) { if (N == &GraphNodes[UniversalSet]) {
llvm_cerr << "<universal>"; cerr << "<universal>";
return; return;
} else if (N == &GraphNodes[NullPtr]) { } else if (N == &GraphNodes[NullPtr]) {
llvm_cerr << "<nullptr>"; cerr << "<nullptr>";
return; return;
} else if (N == &GraphNodes[NullObject]) { } else if (N == &GraphNodes[NullObject]) {
llvm_cerr << "<null>"; cerr << "<null>";
return; return;
} }
@ -1119,56 +1119,56 @@ void Andersens::PrintNode(Node *N) {
if (Function *F = dyn_cast<Function>(V)) { if (Function *F = dyn_cast<Function>(V)) {
if (isa<PointerType>(F->getFunctionType()->getReturnType()) && if (isa<PointerType>(F->getFunctionType()->getReturnType()) &&
N == getReturnNode(F)) { N == getReturnNode(F)) {
llvm_cerr << F->getName() << ":retval"; cerr << F->getName() << ":retval";
return; return;
} else if (F->getFunctionType()->isVarArg() && N == getVarargNode(F)) { } else if (F->getFunctionType()->isVarArg() && N == getVarargNode(F)) {
llvm_cerr << F->getName() << ":vararg"; cerr << F->getName() << ":vararg";
return; return;
} }
} }
if (Instruction *I = dyn_cast<Instruction>(V)) if (Instruction *I = dyn_cast<Instruction>(V))
llvm_cerr << I->getParent()->getParent()->getName() << ":"; cerr << I->getParent()->getParent()->getName() << ":";
else if (Argument *Arg = dyn_cast<Argument>(V)) else if (Argument *Arg = dyn_cast<Argument>(V))
llvm_cerr << Arg->getParent()->getName() << ":"; cerr << Arg->getParent()->getName() << ":";
if (V->hasName()) if (V->hasName())
llvm_cerr << V->getName(); cerr << V->getName();
else else
llvm_cerr << "(unnamed)"; cerr << "(unnamed)";
if (isa<GlobalValue>(V) || isa<AllocationInst>(V)) if (isa<GlobalValue>(V) || isa<AllocationInst>(V))
if (N == getObject(V)) if (N == getObject(V))
llvm_cerr << "<mem>"; cerr << "<mem>";
} }
void Andersens::PrintConstraints() { void Andersens::PrintConstraints() {
llvm_cerr << "Constraints:\n"; cerr << "Constraints:\n";
for (unsigned i = 0, e = Constraints.size(); i != e; ++i) { for (unsigned i = 0, e = Constraints.size(); i != e; ++i) {
llvm_cerr << " #" << i << ": "; cerr << " #" << i << ": ";
Constraint &C = Constraints[i]; Constraint &C = Constraints[i];
if (C.Type == Constraint::Store) if (C.Type == Constraint::Store)
llvm_cerr << "*"; cerr << "*";
PrintNode(C.Dest); PrintNode(C.Dest);
llvm_cerr << " = "; cerr << " = ";
if (C.Type == Constraint::Load) if (C.Type == Constraint::Load)
llvm_cerr << "*"; cerr << "*";
PrintNode(C.Src); PrintNode(C.Src);
llvm_cerr << "\n"; cerr << "\n";
} }
} }
void Andersens::PrintPointsToGraph() { void Andersens::PrintPointsToGraph() {
llvm_cerr << "Points-to graph:\n"; cerr << "Points-to graph:\n";
for (unsigned i = 0, e = GraphNodes.size(); i != e; ++i) { for (unsigned i = 0, e = GraphNodes.size(); i != e; ++i) {
Node *N = &GraphNodes[i]; Node *N = &GraphNodes[i];
llvm_cerr << "[" << (N->end() - N->begin()) << "] "; cerr << "[" << (N->end() - N->begin()) << "] ";
PrintNode(N); PrintNode(N);
llvm_cerr << "\t--> "; cerr << "\t--> ";
for (Node::iterator I = N->begin(), E = N->end(); I != E; ++I) { for (Node::iterator I = N->begin(), E = N->end(); I != E; ++I) {
if (I != N->begin()) llvm_cerr << ", "; if (I != N->begin()) cerr << ", ";
PrintNode(*I); PrintNode(*I);
} }
llvm_cerr << "\n"; cerr << "\n";
} }
} }

View File

@ -74,7 +74,7 @@ public:
AU.setPreservesAll(); AU.setPreservesAll();
} }
void print(llvm_ostream &o, const Module *M) const { void print(OStream &o, const Module *M) const {
if (o.stream()) print(*o.stream(), M); if (o.stream()) print(*o.stream(), M);
} }
@ -95,7 +95,7 @@ public:
/// dump - Print out this call graph. /// dump - Print out this call graph.
/// ///
inline void dump() const { inline void dump() const {
print(llvm_cerr, Mod); print(cerr, Mod);
} }
CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; } CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; }
@ -212,7 +212,7 @@ void CallGraph::print(std::ostream &OS, const Module *M) const {
} }
void CallGraph::dump() const { void CallGraph::dump() const {
print(llvm_cerr, 0); print(cerr, 0);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -275,7 +275,7 @@ void CallGraphNode::print(std::ostream &OS) const {
OS << "\n"; OS << "\n";
} }
void CallGraphNode::dump() const { print(llvm_cerr); } void CallGraphNode::dump() const { print(cerr); }
void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) { void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
for (unsigned i = CalledFunctions.size(); ; --i) { for (unsigned i = CalledFunctions.size(); ; --i) {

View File

@ -43,7 +43,7 @@ namespace {
#include "llvm/Instruction.def" #include "llvm/Instruction.def"
void visitInstruction(Instruction &I) { void visitInstruction(Instruction &I) {
llvm_cerr << "Instruction Count does not know about " << I; cerr << "Instruction Count does not know about " << I;
abort(); abort();
} }
public: public:

View File

@ -80,7 +80,7 @@ void Loop::print(std::ostream &OS, unsigned Depth) const {
} }
void Loop::dump() const { void Loop::dump() const {
print(llvm_cerr); print(cerr);
} }

View File

@ -37,7 +37,7 @@ static void ReadProfilingBlock(const char *ToolName, FILE *F,
// Read the number of entries... // Read the number of entries...
unsigned NumEntries; unsigned NumEntries;
if (fread(&NumEntries, sizeof(unsigned), 1, F) != 1) { if (fread(&NumEntries, sizeof(unsigned), 1, F) != 1) {
llvm_cerr << ToolName << ": data packet truncated!\n"; cerr << ToolName << ": data packet truncated!\n";
perror(0); perror(0);
exit(1); exit(1);
} }
@ -48,7 +48,7 @@ static void ReadProfilingBlock(const char *ToolName, FILE *F,
// Read in the block of data... // Read in the block of data...
if (fread(&TempSpace[0], sizeof(unsigned)*NumEntries, 1, F) != 1) { if (fread(&TempSpace[0], sizeof(unsigned)*NumEntries, 1, F) != 1) {
llvm_cerr << ToolName << ": data packet truncated!\n"; cerr << ToolName << ": data packet truncated!\n";
perror(0); perror(0);
exit(1); exit(1);
} }
@ -75,7 +75,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName,
Module &TheModule) : M(TheModule) { Module &TheModule) : M(TheModule) {
FILE *F = fopen(Filename.c_str(), "r"); FILE *F = fopen(Filename.c_str(), "r");
if (F == 0) { if (F == 0) {
llvm_cerr << ToolName << ": Error opening '" << Filename << "': "; cerr << ToolName << ": Error opening '" << Filename << "': ";
perror(0); perror(0);
exit(1); exit(1);
} }
@ -93,7 +93,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName,
case ArgumentInfo: { case ArgumentInfo: {
unsigned ArgLength; unsigned ArgLength;
if (fread(&ArgLength, sizeof(unsigned), 1, F) != 1) { if (fread(&ArgLength, sizeof(unsigned), 1, F) != 1) {
llvm_cerr << ToolName << ": arguments packet truncated!\n"; cerr << ToolName << ": arguments packet truncated!\n";
perror(0); perror(0);
exit(1); exit(1);
} }
@ -104,7 +104,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName,
if (ArgLength) if (ArgLength)
if (fread(&Chars[0], (ArgLength+3) & ~3, 1, F) != 1) { if (fread(&Chars[0], (ArgLength+3) & ~3, 1, F) != 1) {
llvm_cerr << ToolName << ": arguments packet truncated!\n"; cerr << ToolName << ": arguments packet truncated!\n";
perror(0); perror(0);
exit(1); exit(1);
} }
@ -129,7 +129,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName,
break; break;
default: default:
llvm_cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n"; cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n";
exit(1); exit(1);
} }
} }
@ -156,7 +156,7 @@ void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(), Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(),
BlockCounts[i].second)); BlockCounts[i].second));
} else { } else {
llvm_cerr << "Function counts are not available!\n"; cerr << "Function counts are not available!\n";
} }
return; return;
} }
@ -200,8 +200,8 @@ void ProfileInfoLoader::getBlockCounts(std::vector<std::pair<BasicBlock*,
if (SuccNum >= TI->getNumSuccessors()) { if (SuccNum >= TI->getNumSuccessors()) {
static bool Warned = false; static bool Warned = false;
if (!Warned) { if (!Warned) {
llvm_cerr << "WARNING: profile info doesn't seem to match" cerr << "WARNING: profile info doesn't seem to match"
<< " the program!\n"; << " the program!\n";
Warned = true; Warned = true;
} }
} else { } else {
@ -226,7 +226,7 @@ void ProfileInfoLoader::getBlockCounts(std::vector<std::pair<BasicBlock*,
} }
} else { } else {
llvm_cerr << "Block counts are not available!\n"; cerr << "Block counts are not available!\n";
} }
return; return;
} }
@ -247,8 +247,8 @@ void ProfileInfoLoader::getBlockCounts(std::vector<std::pair<BasicBlock*,
void ProfileInfoLoader::getEdgeCounts(std::vector<std::pair<Edge, void ProfileInfoLoader::getEdgeCounts(std::vector<std::pair<Edge,
unsigned> > &Counts) { unsigned> > &Counts) {
if (EdgeCounts.empty()) { if (EdgeCounts.empty()) {
llvm_cerr << "Edge counts not available, and no synthesis " cerr << "Edge counts not available, and no synthesis "
<< "is implemented yet!\n"; << "is implemented yet!\n";
return; return;
} }
@ -268,9 +268,8 @@ void ProfileInfoLoader::getEdgeCounts(std::vector<std::pair<Edge,
// //
void ProfileInfoLoader::getBBTrace(std::vector<BasicBlock *> &Trace) { void ProfileInfoLoader::getBBTrace(std::vector<BasicBlock *> &Trace) {
if (BBTrace.empty ()) { if (BBTrace.empty ()) {
llvm_cerr << "Basic block trace is not available!\n"; cerr << "Basic block trace is not available!\n";
return; return;
} }
llvm_cerr << "Basic block trace loading is not implemented yet!\n"; cerr << "Basic block trace loading is not implemented yet!\n";
} }

View File

@ -76,8 +76,8 @@ bool LoaderPass::runOnModule(Module &M) {
TerminatorInst *TI = BB->getTerminator(); TerminatorInst *TI = BB->getTerminator();
if (SuccNum >= TI->getNumSuccessors()) { if (SuccNum >= TI->getNumSuccessors()) {
if (!PrintedWarning) { if (!PrintedWarning) {
llvm_cerr << "WARNING: profile information is inconsistent with " cerr << "WARNING: profile information is inconsistent with "
<< "the current program!\n"; << "the current program!\n";
PrintedWarning = true; PrintedWarning = true;
} }
} else { } else {

View File

@ -118,7 +118,7 @@ namespace {
// //
SCEV::~SCEV() {} SCEV::~SCEV() {}
void SCEV::dump() const { void SCEV::dump() const {
print(llvm_cerr); print(cerr);
} }
/// getValueRange - Return the tightest constant bounds that this value is /// getValueRange - Return the tightest constant bounds that this value is
@ -1558,11 +1558,11 @@ SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) {
break; break;
default: default:
#if 0 #if 0
llvm_cerr << "ComputeIterationCount "; cerr << "ComputeIterationCount ";
if (ExitCond->getOperand(0)->getType()->isUnsigned()) if (ExitCond->getOperand(0)->getType()->isUnsigned())
llvm_cerr << "[unsigned] "; cerr << "[unsigned] ";
llvm_cerr << *LHS << " " cerr << *LHS << " "
<< Instruction::getOpcodeName(Cond) << " " << *RHS << "\n"; << Instruction::getOpcodeName(Cond) << " " << *RHS << "\n";
#endif #endif
break; break;
} }
@ -1678,9 +1678,9 @@ ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS,
if (!isa<ConstantBool>(Result)) break; // Couldn't decide for sure if (!isa<ConstantBool>(Result)) break; // Couldn't decide for sure
if (cast<ConstantBool>(Result)->getValue() == false) { if (cast<ConstantBool>(Result)->getValue() == false) {
#if 0 #if 0
llvm_cerr << "\n***\n*** Computed loop count " << *ItCst cerr << "\n***\n*** Computed loop count " << *ItCst
<< "\n*** From global " << *GV << "*** BB: " << *L->getHeader() << "\n*** From global " << *GV << "*** BB: " << *L->getHeader()
<< "***\n"; << "***\n";
#endif #endif
++NumArrayLenItCounts; ++NumArrayLenItCounts;
return SCEVConstant::get(ItCst); // Found terminating iteration! return SCEVConstant::get(ItCst); // Found terminating iteration!
@ -2147,8 +2147,8 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) {
SCEVConstant *R2 = dyn_cast<SCEVConstant>(Roots.second); SCEVConstant *R2 = dyn_cast<SCEVConstant>(Roots.second);
if (R1) { if (R1) {
#if 0 #if 0
llvm_cerr << "HFTZ: " << *V << " - sol#1: " << *R1 cerr << "HFTZ: " << *V << " - sol#1: " << *R1
<< " sol#2: " << *R2 << "\n"; << " sol#2: " << *R2 << "\n";
#endif #endif
// Pick the smallest positive root value. // Pick the smallest positive root value.
assert(R1->getType()->isUnsigned()&&"Didn't canonicalize to unsigned?"); assert(R1->getType()->isUnsigned()&&"Didn't canonicalize to unsigned?");
@ -2276,8 +2276,8 @@ HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L) {
default: break; default: break;
} }
//llvm_cerr << "Computed Loop Trip Count as: " << //cerr << "Computed Loop Trip Count as: "
// *SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)) << "\n"; // << *SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)) << "\n";
return SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)); return SCEV::getMinusSCEV(RHS, AddRec->getOperand(0));
} }
@ -2492,20 +2492,20 @@ static void PrintLoopInfo(std::ostream &OS, const ScalarEvolution *SE,
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
PrintLoopInfo(OS, SE, *I); PrintLoopInfo(OS, SE, *I);
llvm_cerr << "Loop " << L->getHeader()->getName() << ": "; cerr << "Loop " << L->getHeader()->getName() << ": ";
std::vector<BasicBlock*> ExitBlocks; std::vector<BasicBlock*> ExitBlocks;
L->getExitBlocks(ExitBlocks); L->getExitBlocks(ExitBlocks);
if (ExitBlocks.size() != 1) if (ExitBlocks.size() != 1)
llvm_cerr << "<multiple exits> "; cerr << "<multiple exits> ";
if (SE->hasLoopInvariantIterationCount(L)) { if (SE->hasLoopInvariantIterationCount(L)) {
llvm_cerr << *SE->getIterationCount(L) << " iterations! "; cerr << *SE->getIterationCount(L) << " iterations! ";
} else { } else {
llvm_cerr << "Unpredictable iteration count. "; cerr << "Unpredictable iteration count. ";
} }
llvm_cerr << "\n"; cerr << "\n";
} }
void ScalarEvolution::print(std::ostream &OS, const Module* ) const { void ScalarEvolution::print(std::ostream &OS, const Module* ) const {

View File

@ -13,9 +13,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h" #include "llvm/Analysis/ScalarEvolutionExpander.h"
#include "llvm/Analysis/LoopInfo.h"
using namespace llvm; using namespace llvm;
/// InsertCastOfTo - Insert a cast of V to the specified type, doing what /// InsertCastOfTo - Insert a cast of V to the specified type, doing what
@ -175,7 +174,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
SCEVHandle IH = SCEVUnknown::get(I); // Get I as a "symbolic" SCEV. SCEVHandle IH = SCEVUnknown::get(I); // Get I as a "symbolic" SCEV.
SCEVHandle V = S->evaluateAtIteration(IH); SCEVHandle V = S->evaluateAtIteration(IH);
//llvm_cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; //cerr << "Evaluated: " << *this << "\n to: " << *V << "\n";
return expandInTy(V, Ty); return expandInTy(V, Ty);
} }

View File

@ -25,14 +25,13 @@ Function *Trace::getFunction() const {
return getEntryBasicBlock()->getParent(); return getEntryBasicBlock()->getParent();
} }
Module *Trace::getModule() const { Module *Trace::getModule() const {
return getFunction()->getParent(); return getFunction()->getParent();
} }
/// print - Write trace to output stream. /// print - Write trace to output stream.
/// ///
void Trace::print(llvm_ostream &O) const { void Trace::print(OStream &O) const {
Function *F = getFunction (); Function *F = getFunction ();
O << "; Trace from function " << F->getName() << ", blocks:\n"; O << "; Trace from function " << F->getName() << ", blocks:\n";
for (const_iterator i = begin(), e = end(); i != e; ++i) { for (const_iterator i = begin(), e = end(); i != e; ++i) {
@ -48,5 +47,5 @@ void Trace::print(llvm_ostream &O) const {
/// output stream. /// output stream.
/// ///
void Trace::dump() const { void Trace::dump() const {
print(llvm_cerr); print(cerr);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,9 @@
/* A Bison parser, made by GNU Bison 2.1. */ /* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton parser for Yacc-like parsing with Bison, /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -18,10 +20,18 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */ Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a /* As a special exception, you may create a larger work that contains
Bison output file, you may use that output file without restriction. part or all of the Bison parser skeleton and distribute that work
This special exception was added by the Free Software Foundation under terms of your choice, so long as that work isn't itself a
in version 1.24 of Bison. */ parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
@ -320,9 +330,10 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
#line 855 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" typedef union YYSTYPE
typedef union YYSTYPE { #line 855 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y"
{
llvm::Module *ModuleVal; llvm::Module *ModuleVal;
llvm::Function *FunctionVal; llvm::Function *FunctionVal;
std::pair<llvm::PATypeHolder*, char*> *ArgVal; std::pair<llvm::PATypeHolder*, char*> *ArgVal;
@ -363,9 +374,10 @@ typedef union YYSTYPE {
llvm::Module::Endianness Endianness; llvm::Module::Endianness Endianness;
llvm::ICmpInst::Predicate IPredicate; llvm::ICmpInst::Predicate IPredicate;
llvm::FCmpInst::Predicate FPredicate; llvm::FCmpInst::Predicate FPredicate;
} YYSTYPE; }
/* Line 1447 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 369 "llvmAsmParser.tab.h" #line 380 "llvmAsmParser.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
@ -373,5 +385,3 @@ typedef union YYSTYPE {
extern YYSTYPE llvmAsmlval; extern YYSTYPE llvmAsmlval;

View File

@ -57,7 +57,7 @@ static Module *ParserResult;
// //
//#define DEBUG_UPREFS 1 //#define DEBUG_UPREFS 1
#ifdef DEBUG_UPREFS #ifdef DEBUG_UPREFS
#define UR_OUT(X) llvm_cerr << X #define UR_OUT(X) cerr << X
#else #else
#define UR_OUT(X) #define UR_OUT(X)
#endif #endif
@ -2390,8 +2390,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
GEN_ERROR("fcmp operator returned null!"); GEN_ERROR("fcmp operator returned null!");
} }
| NOT ResolvedVal { | NOT ResolvedVal {
llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" cerr << "WARNING: Use of eliminated 'not' instruction:"
<< " Replacing with 'xor'.\n"; << " Replacing with 'xor'.\n";
Value *Ones = ConstantIntegral::getAllOnesValue($2->getType()); Value *Ones = ConstantIntegral::getAllOnesValue($2->getType());
if (Ones == 0) if (Ones == 0)

View File

@ -57,7 +57,7 @@ static Module *ParserResult;
// //
//#define DEBUG_UPREFS 1 //#define DEBUG_UPREFS 1
#ifdef DEBUG_UPREFS #ifdef DEBUG_UPREFS
#define UR_OUT(X) llvm_cerr << X #define UR_OUT(X) cerr << X
#else #else
#define UR_OUT(X) #define UR_OUT(X)
#endif #endif
@ -2390,8 +2390,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
GEN_ERROR("fcmp operator returned null!"); GEN_ERROR("fcmp operator returned null!");
} }
| NOT ResolvedVal { | NOT ResolvedVal {
llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" cerr << "WARNING: Use of eliminated 'not' instruction:"
<< " Replacing with 'xor'.\n"; << " Replacing with 'xor'.\n";
Value *Ones = ConstantIntegral::getAllOnesValue($2->getType()); Value *Ones = ConstantIntegral::getAllOnesValue($2->getType());
if (Ones == 0) if (Ones == 0)

View File

@ -32,7 +32,7 @@ using namespace llvm;
#if 0 #if 0
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#define SC_DEBUG(X) llvm_cerr << X #define SC_DEBUG(X) cerr << X
#else #else
#define SC_DEBUG(X) #define SC_DEBUG(X)
#endif #endif

View File

@ -276,8 +276,8 @@ void BytecodeWriter::outputType(const Type *T) {
break; break;
default: default:
llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize"
<< " Type '" << T->getDescription() << "'\n"; << " Type '" << T->getDescription() << "'\n";
break; break;
} }
} }
@ -387,8 +387,8 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
case Type::VoidTyID: case Type::VoidTyID:
case Type::LabelTyID: case Type::LabelTyID:
default: default:
llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize"
<< " type '" << *CPV->getType() << "'\n"; << " type '" << *CPV->getType() << "'\n";
break; break;
} }
return; return;
@ -1239,13 +1239,13 @@ void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
} }
} }
void llvm::WriteBytecodeToFile(const Module *M, llvm_ostream &Out, void llvm::WriteBytecodeToFile(const Module *M, OStream &Out,
bool compress) { bool compress) {
assert(M && "You can't write a null module!!"); assert(M && "You can't write a null module!!");
// Make sure that std::cout is put into binary mode for systems // Make sure that std::cout is put into binary mode for systems
// that care. // that care.
if (Out == llvm_cout) if (Out == cout)
sys::Program::ChangeStdoutToBinary(); sys::Program::ChangeStdoutToBinary();
// Create a vector of unsigned char for the bytecode output. We // Create a vector of unsigned char for the bytecode output. We

View File

@ -25,7 +25,6 @@
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include <ostream>
#include <cerrno> #include <cerrno>
using namespace llvm; using namespace llvm;
@ -668,8 +667,8 @@ void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
if (LastMI != MI) { ++Counter; LastMI = MI; } if (LastMI != MI) { ++Counter; LastMI = MI; }
O << Counter; O << Counter;
} else { } else {
llvm_cerr << "Unknown special formatter '" << Code cerr << "Unknown special formatter '" << Code
<< "' for machine instr: " << *MI; << "' for machine instr: " << *MI;
exit(1); exit(1);
} }
} }
@ -737,8 +736,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
case '(': // $( -> same as GCC's { character. case '(': // $( -> same as GCC's { character.
++LastEmitted; // Consume '(' character. ++LastEmitted; // Consume '(' character.
if (CurVariant != -1) { if (CurVariant != -1) {
llvm_cerr << "Nested variants found in inline asm string: '" cerr << "Nested variants found in inline asm string: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
exit(1); exit(1);
} }
CurVariant = 0; // We're in the first variant now. CurVariant = 0; // We're in the first variant now.
@ -746,8 +745,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
case '|': case '|':
++LastEmitted; // consume '|' character. ++LastEmitted; // consume '|' character.
if (CurVariant == -1) { if (CurVariant == -1) {
llvm_cerr << "Found '|' character outside of variant in inline asm " cerr << "Found '|' character outside of variant in inline asm "
<< "string: '" << AsmStr << "'\n"; << "string: '" << AsmStr << "'\n";
exit(1); exit(1);
} }
++CurVariant; // We're in the next variant. ++CurVariant; // We're in the next variant.
@ -755,8 +754,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
case ')': // $) -> same as GCC's } char. case ')': // $) -> same as GCC's } char.
++LastEmitted; // consume ')' character. ++LastEmitted; // consume ')' character.
if (CurVariant == -1) { if (CurVariant == -1) {
llvm_cerr << "Found '}' character outside of variant in inline asm " cerr << "Found '}' character outside of variant in inline asm "
<< "string: '" << AsmStr << "'\n"; << "string: '" << AsmStr << "'\n";
exit(1); exit(1);
} }
CurVariant = -1; CurVariant = -1;
@ -774,8 +773,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
char *IDEnd; char *IDEnd;
long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs. long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) { if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
llvm_cerr << "Bad $ operand number in inline asm string: '" cerr << "Bad $ operand number in inline asm string: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
exit(1); exit(1);
} }
LastEmitted = IDEnd; LastEmitted = IDEnd;
@ -788,8 +787,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
if (*LastEmitted == ':') { if (*LastEmitted == ':') {
++LastEmitted; // Consume ':' character. ++LastEmitted; // Consume ':' character.
if (*LastEmitted == 0) { if (*LastEmitted == 0) {
llvm_cerr << "Bad ${:} expression in inline asm string: '" cerr << "Bad ${:} expression in inline asm string: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
exit(1); exit(1);
} }
@ -798,16 +797,16 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
} }
if (*LastEmitted != '}') { if (*LastEmitted != '}') {
llvm_cerr << "Bad ${} expression in inline asm string: '" cerr << "Bad ${} expression in inline asm string: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
exit(1); exit(1);
} }
++LastEmitted; // Consume '}' character. ++LastEmitted; // Consume '}' character.
} }
if ((unsigned)Val >= NumOperands-1) { if ((unsigned)Val >= NumOperands-1) {
llvm_cerr << "Invalid $ operand number in inline asm string: '" cerr << "Invalid $ operand number in inline asm string: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
exit(1); exit(1);
} }
@ -841,8 +840,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
} }
} }
if (Error) { if (Error) {
llvm_cerr << "Invalid operand found in inline asm: '" cerr << "Invalid operand found in inline asm: '"
<< AsmStr << "'\n"; << AsmStr << "'\n";
MI->dump(); MI->dump();
exit(1); exit(1);
} }

View File

@ -31,10 +31,8 @@
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetFrameInfo.h"
#include <ostream> #include <ostream>
#include <string> #include <string>
using namespace llvm; using namespace llvm;
using namespace llvm::dwarf; using namespace llvm::dwarf;
@ -139,7 +137,7 @@ public:
} }
#ifndef NDEBUG #ifndef NDEBUG
void print(llvm_ostream &O) const { void print(OStream &O) const {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O) const { void print(std::ostream &O) const {
@ -247,7 +245,7 @@ public:
void Emit(const Dwarf &DW) const; void Emit(const Dwarf &DW) const;
#ifndef NDEBUG #ifndef NDEBUG
void print(llvm_ostream &O) { void print(OStream &O) {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
void print(std::ostream &O); void print(std::ostream &O);
@ -337,7 +335,7 @@ public:
void Profile(FoldingSetNodeID &ID) ; void Profile(FoldingSetNodeID &ID) ;
#ifndef NDEBUG #ifndef NDEBUG
void print(llvm_ostream &O, unsigned IncIndent = 0) { void print(OStream &O, unsigned IncIndent = 0) {
if (O.stream()) print(*O.stream(), IncIndent); if (O.stream()) print(*O.stream(), IncIndent);
} }
void print(std::ostream &O, unsigned IncIndent = 0); void print(std::ostream &O, unsigned IncIndent = 0);
@ -388,7 +386,7 @@ public:
virtual void Profile(FoldingSetNodeID &ID) = 0; virtual void Profile(FoldingSetNodeID &ID) = 0;
#ifndef NDEBUG #ifndef NDEBUG
void print(llvm_ostream &O) { void print(OStream &O) {
if (O.stream()) print(*O.stream()); if (O.stream()) print(*O.stream());
} }
virtual void print(std::ostream &O) = 0; virtual void print(std::ostream &O) = 0;
@ -2861,14 +2859,14 @@ void DIEAbbrev::print(std::ostream &O) {
<< "\n"; << "\n";
} }
} }
void DIEAbbrev::dump() { print(llvm_cerr); } void DIEAbbrev::dump() { print(cerr); }
#endif #endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef NDEBUG #ifndef NDEBUG
void DIEValue::dump() { void DIEValue::dump() {
print(llvm_cerr); print(cerr);
} }
#endif #endif
@ -3079,7 +3077,7 @@ void DIE::print(std::ostream &O, unsigned IncIndent) {
} }
void DIE::dump() { void DIE::dump() {
print(llvm_cerr); print(cerr);
} }
#endif #endif

View File

@ -39,7 +39,6 @@
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Mangler.h" #include "llvm/Support/Mangler.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include <ostream>
using namespace llvm; using namespace llvm;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -104,9 +103,9 @@ void ELFCodeEmitter::startFunction(MachineFunction &F) {
ELFWriter::ELFSection::SHF_EXECINSTR | ELFWriter::ELFSection::SHF_EXECINSTR |
ELFWriter::ELFSection::SHF_ALLOC); ELFWriter::ELFSection::SHF_ALLOC);
OutBuffer = &ES->SectionData; OutBuffer = &ES->SectionData;
llvm_cerr << "FIXME: This code needs to be updated for changes in the" cerr << "FIXME: This code needs to be updated for changes in the"
<< " CodeEmitter interfaces. In particular, this should set " << " CodeEmitter interfaces. In particular, this should set "
<< "BufferBegin/BufferEnd/CurBufferPtr, not deal with OutBuffer!"; << "BufferBegin/BufferEnd/CurBufferPtr, not deal with OutBuffer!";
abort(); abort();
// Upgrade the section alignment if required. // Upgrade the section alignment if required.

View File

@ -274,12 +274,12 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
switch (Callee->getIntrinsicID()) { switch (Callee->getIntrinsicID()) {
case Intrinsic::not_intrinsic: case Intrinsic::not_intrinsic:
llvm_cerr << "Cannot lower a call to a non-intrinsic function '" cerr << "Cannot lower a call to a non-intrinsic function '"
<< Callee->getName() << "'!\n"; << Callee->getName() << "'!\n";
abort(); abort();
default: default:
llvm_cerr << "Error: Code generator does not support intrinsic function '" cerr << "Error: Code generator does not support intrinsic function '"
<< Callee->getName() << "'!\n"; << Callee->getName() << "'!\n";
abort(); abort();
// The setjmp/longjmp intrinsics should only exist in the code if it was // The setjmp/longjmp intrinsics should only exist in the code if it was
@ -356,9 +356,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::stackrestore: { case Intrinsic::stackrestore: {
static bool Warned = false; static bool Warned = false;
if (!Warned) if (!Warned)
llvm_cerr << "WARNING: this target does not support the llvm.stack" cerr << "WARNING: this target does not support the llvm.stack"
<< (Callee->getIntrinsicID() == Intrinsic::stacksave ? << (Callee->getIntrinsicID() == Intrinsic::stacksave ?
"save" : "restore") << " intrinsic.\n"; "save" : "restore") << " intrinsic.\n";
Warned = true; Warned = true;
if (Callee->getIntrinsicID() == Intrinsic::stacksave) if (Callee->getIntrinsicID() == Intrinsic::stacksave)
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
@ -367,9 +367,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::returnaddress: case Intrinsic::returnaddress:
case Intrinsic::frameaddress: case Intrinsic::frameaddress:
llvm_cerr << "WARNING: this target does not support the llvm." cerr << "WARNING: this target does not support the llvm."
<< (Callee->getIntrinsicID() == Intrinsic::returnaddress ? << (Callee->getIntrinsicID() == Intrinsic::returnaddress ?
"return" : "frame") << "address intrinsic.\n"; "return" : "frame") << "address intrinsic.\n";
CI->replaceAllUsesWith(ConstantPointerNull::get( CI->replaceAllUsesWith(ConstantPointerNull::get(
cast<PointerType>(CI->getType()))); cast<PointerType>(CI->getType())));
break; break;
@ -380,8 +380,8 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::pcmarker: case Intrinsic::pcmarker:
break; // Simply strip out pcmarker on unsupported architectures break; // Simply strip out pcmarker on unsupported architectures
case Intrinsic::readcyclecounter: { case Intrinsic::readcyclecounter: {
llvm_cerr << "WARNING: this target does not support the llvm.readcyclecoun" cerr << "WARNING: this target does not support the llvm.readcyclecoun"
<< "ter intrinsic. It is being lowered to a constant 0\n"; << "ter intrinsic. It is being lowered to a constant 0\n";
CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, 0)); CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, 0));
break; break;
} }

View File

@ -23,7 +23,6 @@
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/MRegisterInfo.h"
#include <algorithm> #include <algorithm>
#include <iostream>
#include <map> #include <map>
using namespace llvm; using namespace llvm;
@ -472,10 +471,10 @@ std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) {
} }
void LiveRange::dump() const { void LiveRange::dump() const {
llvm_cerr << *this << "\n"; cerr << *this << "\n";
} }
void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const { void LiveInterval::print(OStream OS, const MRegisterInfo *MRI) const {
if (MRI && MRegisterInfo::isPhysicalRegister(reg)) if (MRI && MRegisterInfo::isPhysicalRegister(reg))
OS << MRI->getName(reg); OS << MRI->getName(reg);
else else
@ -508,5 +507,5 @@ void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const {
} }
void LiveInterval::dump() const { void LiveInterval::dump() const {
llvm_cerr << *this << "\n"; cerr << *this << "\n";
} }

View File

@ -419,9 +419,9 @@ addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, int slot) {
void LiveIntervals::printRegName(unsigned reg) const { void LiveIntervals::printRegName(unsigned reg) const {
if (MRegisterInfo::isPhysicalRegister(reg)) if (MRegisterInfo::isPhysicalRegister(reg))
llvm_cerr << mri_->getName(reg); cerr << mri_->getName(reg);
else else
llvm_cerr << "%reg" << reg; cerr << "%reg" << reg;
} }
/// isReDefinedByTwoAddr - Returns true if the Reg re-definition is due to /// isReDefinedByTwoAddr - Returns true if the Reg re-definition is due to

View File

@ -18,7 +18,6 @@
#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/MRegisterInfo.h"
#include "llvm/Support/LeakDetector.h" #include "llvm/Support/LeakDetector.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include <iostream>
using namespace llvm; using namespace llvm;
/// MachineInstr ctor - This constructor creates a dummy MachineInstr with /// MachineInstr ctor - This constructor creates a dummy MachineInstr with
@ -201,7 +200,7 @@ void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) {
} }
void MachineInstr::dump() const { void MachineInstr::dump() const {
llvm_cerr << " " << *this; cerr << " " << *this;
} }
static inline void OutputReg(std::ostream &os, unsigned RegNo, static inline void OutputReg(std::ostream &os, unsigned RegNo,

View File

@ -112,11 +112,11 @@ void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
} }
void VirtRegMap::print(std::ostream &OS) const { void VirtRegMap::print(std::ostream &OS) const {
llvm_ostream LOS(OS); OStream LOS(OS);
print(LOS); print(LOS);
} }
void VirtRegMap::print(llvm_ostream &OS) const { void VirtRegMap::print(OStream &OS) const {
const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo(); const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo();
OS << "********** REGISTER MAP **********\n"; OS << "********** REGISTER MAP **********\n";
@ -135,7 +135,7 @@ void VirtRegMap::print(llvm_ostream &OS) const {
} }
void VirtRegMap::dump() const { void VirtRegMap::dump() const {
llvm_ostream OS = DOUT; OStream OS = DOUT;
print(OS); print(OS);
} }

View File

@ -19,12 +19,12 @@
#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/MRegisterInfo.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Streams.h"
#include <map> #include <map>
namespace llvm { namespace llvm {
class MachineInstr; class MachineInstr;
class TargetInstrInfo; class TargetInstrInfo;
class llvm_ostream;
class VirtRegMap { class VirtRegMap {
public: public:
@ -145,7 +145,7 @@ namespace llvm {
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;
void print(llvm_ostream &OS) const; void print(OStream &OS) const;
void dump() const; void dump() const;
}; };

View File

@ -402,7 +402,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
default: default:
break; break;
} }
llvm_cerr << "ConstantExpr not handled as global var init: " << *CE << "\n"; cerr << "ConstantExpr not handled as global var init: " << *CE << "\n";
abort(); abort();
} }
@ -432,7 +432,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
assert(0 && "Unknown constant pointer type!"); assert(0 && "Unknown constant pointer type!");
break; break;
default: default:
llvm_cerr << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; cerr << "ERROR: Constant unimp for type: " << *C->getType() << "\n";
abort(); abort();
} }
return Result; return Result;
@ -477,7 +477,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
Ptr->Untyped[7] = (unsigned char)(Val.ULongVal >> 56); Ptr->Untyped[7] = (unsigned char)(Val.ULongVal >> 56);
break; break;
default: default:
llvm_cerr << "Cannot store value of type " << *Ty << "!\n"; cerr << "Cannot store value of type " << *Ty << "!\n";
} }
} else { } else {
switch (Ty->getTypeID()) { switch (Ty->getTypeID()) {
@ -511,7 +511,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
Ptr->Untyped[0] = (unsigned char)(Val.ULongVal >> 56); Ptr->Untyped[0] = (unsigned char)(Val.ULongVal >> 56);
break; break;
default: default:
llvm_cerr << "Cannot store value of type " << *Ty << "!\n"; cerr << "Cannot store value of type " << *Ty << "!\n";
} }
} }
} }
@ -552,7 +552,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
((uint64_t)Ptr->Untyped[7] << 56); ((uint64_t)Ptr->Untyped[7] << 56);
break; break;
default: default:
llvm_cerr << "Cannot load value of type " << *Ty << "!\n"; cerr << "Cannot load value of type " << *Ty << "!\n";
abort(); abort();
} }
} else { } else {
@ -586,7 +586,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
((uint64_t)Ptr->Untyped[0] << 56); ((uint64_t)Ptr->Untyped[0] << 56);
break; break;
default: default:
llvm_cerr << "Cannot load value of type " << *Ty << "!\n"; cerr << "Cannot load value of type " << *Ty << "!\n";
abort(); abort();
} }
} }
@ -634,7 +634,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
} }
default: default:
llvm_cerr << "Bad Type: " << *Init->getType() << "\n"; cerr << "Bad Type: " << *Init->getType() << "\n";
assert(0 && "Unknown constant type to initialize memory with!"); assert(0 && "Unknown constant type to initialize memory with!");
} }
} }
@ -718,8 +718,8 @@ void ExecutionEngine::emitGlobals() {
sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str())) sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str()))
addGlobalMapping(I, SymAddr); addGlobalMapping(I, SymAddr);
else { else {
llvm_cerr << "Could not resolve external global address: " cerr << "Could not resolve external global address: "
<< I->getName() << "\n"; << I->getName() << "\n";
abort(); abort();
} }
} }

View File

@ -188,7 +188,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
getOperandValue(CE->getOperand(1), SF), getOperandValue(CE->getOperand(1), SF),
getOperandValue(CE->getOperand(2), SF)); getOperandValue(CE->getOperand(2), SF));
default: default:
llvm_cerr << "Unhandled ConstantExpr: " << *CE << "\n"; cerr << "Unhandled ConstantExpr: " << *CE << "\n";
abort(); abort();
return GenericValue(); return GenericValue();
} }
@ -236,7 +236,7 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(+, Float); IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double); IMPLEMENT_BINARY_OPERATOR(+, Double);
default: default:
llvm_cerr << "Unhandled type for Add instruction: " << *Ty << "\n"; cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -257,7 +257,7 @@ static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(-, Float); IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double); IMPLEMENT_BINARY_OPERATOR(-, Double);
default: default:
llvm_cerr << "Unhandled type for Sub instruction: " << *Ty << "\n"; cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -278,7 +278,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(*, Float); IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double); IMPLEMENT_BINARY_OPERATOR(*, Double);
default: default:
llvm_cerr << "Unhandled type for Mul instruction: " << *Ty << "\n"; cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -296,7 +296,7 @@ static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int);
IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long); IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long);
default: default:
llvm_cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n"; cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -311,7 +311,7 @@ static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt);
IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong); IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong);
default: default:
llvm_cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n"; cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -324,7 +324,7 @@ static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Float);
IMPLEMENT_BINARY_OPERATOR(/, Double); IMPLEMENT_BINARY_OPERATOR(/, Double);
default: default:
llvm_cerr << "Unhandled type for Div instruction: " << *Ty << "\n"; cerr << "Unhandled type for Div instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -339,7 +339,7 @@ static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(%, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(%, UInt, Int);
IMPLEMENT_SIGNLESS_BINOP(%, ULong, Long); IMPLEMENT_SIGNLESS_BINOP(%, ULong, Long);
default: default:
llvm_cerr << "Unhandled type for URem instruction: " << *Ty << "\n"; cerr << "Unhandled type for URem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -354,7 +354,7 @@ static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(%, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(%, Int, UInt);
IMPLEMENT_SIGNLESS_BINOP(%, Long, ULong); IMPLEMENT_SIGNLESS_BINOP(%, Long, ULong);
default: default:
llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -371,7 +371,7 @@ static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
break; break;
default: default:
llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -391,7 +391,7 @@ static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(&, ULong); IMPLEMENT_BINARY_OPERATOR(&, ULong);
IMPLEMENT_BINARY_OPERATOR(&, Long); IMPLEMENT_BINARY_OPERATOR(&, Long);
default: default:
llvm_cerr << "Unhandled type for And instruction: " << *Ty << "\n"; cerr << "Unhandled type for And instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -411,7 +411,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(|, ULong); IMPLEMENT_BINARY_OPERATOR(|, ULong);
IMPLEMENT_BINARY_OPERATOR(|, Long); IMPLEMENT_BINARY_OPERATOR(|, Long);
default: default:
llvm_cerr << "Unhandled type for Or instruction: " << *Ty << "\n"; cerr << "Unhandled type for Or instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -431,7 +431,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(^, ULong); IMPLEMENT_BINARY_OPERATOR(^, ULong);
IMPLEMENT_BINARY_OPERATOR(^, Long); IMPLEMENT_BINARY_OPERATOR(^, Long);
default: default:
llvm_cerr << "Unhandled type for Xor instruction: " << *Ty << "\n"; cerr << "Unhandled type for Xor instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -465,7 +465,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(==, Double); IMPLEMENT_SETCC(==, Double);
IMPLEMENT_POINTERSETCC(==); IMPLEMENT_POINTERSETCC(==);
default: default:
llvm_cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -488,7 +488,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTERSETCC(!=); IMPLEMENT_POINTERSETCC(!=);
default: default:
llvm_cerr << "Unhandled type for SetNE instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetNE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -510,7 +510,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<=, Double); IMPLEMENT_SETCC(<=, Double);
IMPLEMENT_POINTERSETCC(<=); IMPLEMENT_POINTERSETCC(<=);
default: default:
llvm_cerr << "Unhandled type for SetLE instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetLE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -532,7 +532,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>=, Double); IMPLEMENT_SETCC(>=, Double);
IMPLEMENT_POINTERSETCC(>=); IMPLEMENT_POINTERSETCC(>=);
default: default:
llvm_cerr << "Unhandled type for SetGE instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetGE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -554,7 +554,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<, Double); IMPLEMENT_SETCC(<, Double);
IMPLEMENT_POINTERSETCC(<); IMPLEMENT_POINTERSETCC(<);
default: default:
llvm_cerr << "Unhandled type for SetLT instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetLT instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -576,7 +576,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>, Double); IMPLEMENT_SETCC(>, Double);
IMPLEMENT_POINTERSETCC(>); IMPLEMENT_POINTERSETCC(>);
default: default:
llvm_cerr << "Unhandled type for SetGT instruction: " << *Ty << "\n"; cerr << "Unhandled type for SetGT instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -609,7 +609,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break; case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break;
case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break; case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break;
default: default:
llvm_cerr << "Don't know how to handle this binary operator!\n-->" << I; cerr << "Don't know how to handle this binary operator!\n-->" << I;
abort(); abort();
} }
@ -710,7 +710,7 @@ void Interpreter::visitUnwindInst(UnwindInst &I) {
} }
void Interpreter::visitUnreachableInst(UnreachableInst &I) { void Interpreter::visitUnreachableInst(UnreachableInst &I) {
llvm_cerr << "ERROR: Program executed an 'unreachable' instruction!\n"; cerr << "ERROR: Program executed an 'unreachable' instruction!\n";
abort(); abort();
} }
@ -978,7 +978,7 @@ static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SHIFT(<<, ULong); IMPLEMENT_SHIFT(<<, ULong);
IMPLEMENT_SHIFT(<<, Long); IMPLEMENT_SHIFT(<<, Long);
default: default:
llvm_cerr << "Unhandled type for Shl instruction: " << *Ty << "\n"; cerr << "Unhandled type for Shl instruction: " << *Ty << "\n";
} }
return Dest; return Dest;
} }
@ -992,7 +992,7 @@ static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_SHIFT(>>, UInt, Int); IMPLEMENT_SIGNLESS_SHIFT(>>, UInt, Int);
IMPLEMENT_SIGNLESS_SHIFT(>>, ULong, Long); IMPLEMENT_SIGNLESS_SHIFT(>>, ULong, Long);
default: default:
llvm_cerr << "Unhandled type for LShr instruction: " << *Ty << "\n"; cerr << "Unhandled type for LShr instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -1007,7 +1007,7 @@ static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_SHIFT(>>, Int, UInt); IMPLEMENT_SIGNLESS_SHIFT(>>, Int, UInt);
IMPLEMENT_SIGNLESS_SHIFT(>>, Long, ULong); IMPLEMENT_SIGNLESS_SHIFT(>>, Long, ULong);
default: default:
llvm_cerr << "Unhandled type for AShr instruction: " << *Ty << "\n"; cerr << "Unhandled type for AShr instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -1065,14 +1065,14 @@ void Interpreter::visitAShr(ShiftInst &I) {
IMPLEMENT_CAST(DESTTY, DESTCTY, Float); \ IMPLEMENT_CAST(DESTTY, DESTCTY, Float); \
IMPLEMENT_CAST(DESTTY, DESTCTY, Double) \ IMPLEMENT_CAST(DESTTY, DESTCTY, Double) \
default: \ default: \
llvm_cerr << "Unhandled cast: " \ cerr << "Unhandled cast: " \
<< *SrcTy << " to " << *DstTy << "\n"; \ << *SrcTy << " to " << *DstTy << "\n"; \
abort(); \ abort(); \
} \ } \
break break
#define IMPLEMENT_CAST_END \ #define IMPLEMENT_CAST_END \
default: llvm_cerr \ default: cerr \
<< "Unhandled dest type for cast instruction: " \ << "Unhandled dest type for cast instruction: " \
<< *DstTy << "\n"; \ << *DstTy << "\n"; \
abort(); \ abort(); \
@ -1226,8 +1226,7 @@ GenericValue Interpreter::executeCastOperation(Instruction::CastOps opcode,
IMPLEMENT_CAST_END IMPLEMENT_CAST_END
break; break;
default: default:
llvm_cerr cerr << "Invalid cast opcode for cast instruction: " << opcode << "\n";
<< "Invalid cast opcode for cast instruction: " << opcode << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -1266,7 +1265,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
IMPLEMENT_VAARG(Double); IMPLEMENT_VAARG(Double);
IMPLEMENT_VAARG(Bool); IMPLEMENT_VAARG(Bool);
default: default:
llvm_cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n"; cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
abort(); abort();
} }

View File

@ -93,8 +93,8 @@ GenericValue Interpreter::callExternalFunction(Function *F,
std::map<const Function *, ExFunc>::iterator FI = Functions.find(F); std::map<const Function *, ExFunc>::iterator FI = Functions.find(F);
ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second; ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second;
if (Fn == 0) { if (Fn == 0) {
llvm_cerr << "Tried to execute an unknown external function: " cerr << "Tried to execute an unknown external function: "
<< F->getType()->getDescription() << " " << F->getName() << "\n"; << F->getType()->getDescription() << " " << F->getName() << "\n";
if (F->getName() == "__main") if (F->getName() == "__main")
return GenericValue(); return GenericValue();
abort(); abort();
@ -114,19 +114,19 @@ extern "C" { // Don't add C++ manglings to llvm mangling :)
// void putchar(sbyte) // void putchar(sbyte)
GenericValue lle_Vb_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_Vb_putchar(FunctionType *M, const vector<GenericValue> &Args) {
llvm_cout << Args[0].SByteVal; cout << Args[0].SByteVal;
return GenericValue(); return GenericValue();
} }
// int putchar(int) // int putchar(int)
GenericValue lle_ii_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_ii_putchar(FunctionType *M, const vector<GenericValue> &Args) {
llvm_cout << ((char)Args[0].IntVal) << std::flush; cout << ((char)Args[0].IntVal) << std::flush;
return Args[0]; return Args[0];
} }
// void putchar(ubyte) // void putchar(ubyte)
GenericValue lle_VB_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_VB_putchar(FunctionType *M, const vector<GenericValue> &Args) {
llvm_cout << Args[0].SByteVal << std::flush; cout << Args[0].SByteVal << std::flush;
return Args[0]; return Args[0];
} }
@ -332,7 +332,7 @@ GenericValue lle_X_sprintf(FunctionType *M, const vector<GenericValue> &Args) {
sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break; sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break;
case 's': case 's':
sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break; sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break;
default: llvm_cerr << "<unknown printf code '" << *FmtStr << "'!>"; default: cerr << "<unknown printf code '" << *FmtStr << "'!>";
ArgNo++; break; ArgNo++; break;
} }
strcpy(OutputBuffer, Buffer); strcpy(OutputBuffer, Buffer);
@ -350,7 +350,7 @@ GenericValue lle_X_printf(FunctionType *M, const vector<GenericValue> &Args) {
NewArgs.push_back(PTOGV(Buffer)); NewArgs.push_back(PTOGV(Buffer));
NewArgs.insert(NewArgs.end(), Args.begin(), Args.end()); NewArgs.insert(NewArgs.end(), Args.begin(), Args.end());
GenericValue GV = lle_X_sprintf(M, NewArgs); GenericValue GV = lle_X_sprintf(M, NewArgs);
llvm_cout << Buffer; cout << Buffer;
return GV; return GV;
} }

View File

@ -25,7 +25,6 @@
#include "llvm/Assembly/Writer.h" #include "llvm/Assembly/Writer.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include "llvm/System/Path.h" #include "llvm/System/Path.h"
#include <sstream>
using namespace llvm; using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true. // Error - Simple wrapper function to conditionally assign to E and return true.
@ -251,11 +250,11 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
static void PrintMap(const std::map<const Value*, Value*> &M) { static void PrintMap(const std::map<const Value*, Value*> &M) {
for (std::map<const Value*, Value*>::const_iterator I = M.begin(), E =M.end(); for (std::map<const Value*, Value*>::const_iterator I = M.begin(), E =M.end();
I != E; ++I) { I != E; ++I) {
llvm_cerr << " Fr: " << (void*)I->first << " "; cerr << " Fr: " << (void*)I->first << " ";
I->first->dump(); I->first->dump();
llvm_cerr << " To: " << (void*)I->second << " "; cerr << " To: " << (void*)I->second << " ";
I->second->dump(); I->second->dump();
llvm_cerr << "\n"; cerr << "\n";
} }
} }
@ -313,10 +312,10 @@ static Value *RemapOperand(const Value *In,
} }
llvm_cerr << "LinkModules ValueMap: \n"; cerr << "LinkModules ValueMap: \n";
PrintMap(ValueMap); PrintMap(ValueMap);
llvm_cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n"; cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n";
assert(0 && "Couldn't remap value!"); assert(0 && "Couldn't remap value!");
return 0; return 0;
} }
@ -844,13 +843,13 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
if (Src->getEndianness() != Module::AnyEndianness && if (Src->getEndianness() != Module::AnyEndianness &&
Dest->getEndianness() != Src->getEndianness()) Dest->getEndianness() != Src->getEndianness())
llvm_cerr << "WARNING: Linking two modules of different endianness!\n"; cerr << "WARNING: Linking two modules of different endianness!\n";
if (Src->getPointerSize() != Module::AnyPointerSize && if (Src->getPointerSize() != Module::AnyPointerSize &&
Dest->getPointerSize() != Src->getPointerSize()) Dest->getPointerSize() != Src->getPointerSize())
llvm_cerr << "WARNING: Linking two modules of different pointer size!\n"; cerr << "WARNING: Linking two modules of different pointer size!\n";
if (!Src->getTargetTriple().empty() && if (!Src->getTargetTriple().empty() &&
Dest->getTargetTriple() != Src->getTargetTriple()) Dest->getTargetTriple() != Src->getTargetTriple())
llvm_cerr << "WARNING: Linking two modules of different target triples!\n"; cerr << "WARNING: Linking two modules of different target triples!\n";
if (!Src->getModuleInlineAsm().empty()) { if (!Src->getModuleInlineAsm().empty()) {
if (Dest->getModuleInlineAsm().empty()) if (Dest->getModuleInlineAsm().empty())

View File

@ -45,7 +45,7 @@ bool
Linker::error(const std::string& message) { Linker::error(const std::string& message) {
Error = message; Error = message;
if (!(Flags&QuietErrors)) if (!(Flags&QuietErrors))
llvm_cerr << ProgramName << ": error: " << message << "\n"; cerr << ProgramName << ": error: " << message << "\n";
return true; return true;
} }
@ -53,14 +53,14 @@ bool
Linker::warning(const std::string& message) { Linker::warning(const std::string& message) {
Error = message; Error = message;
if (!(Flags&QuietErrors)) if (!(Flags&QuietErrors))
llvm_cerr << ProgramName << ": warning: " << message << "\n"; cerr << ProgramName << ": warning: " << message << "\n";
return false; return false;
} }
void void
Linker::verbose(const std::string& message) { Linker::verbose(const std::string& message) {
if (Flags&Verbose) if (Flags&Verbose)
llvm_cerr << " " << message << "\n"; cerr << " " << message << "\n";
} }
void void

View File

@ -102,6 +102,6 @@ void BumpPtrAllocator::PrintStats() const {
for (; R; R = R->getNext(), ++NumRegions) for (; R; R = R->getNext(), ++NumRegions)
BytesUsed += R->getNumBytesAllocated(); BytesUsed += R->getNumBytesAllocated();
llvm_cerr << "\nNumber of memory regions: " << NumRegions << "\n"; cerr << "\nNumber of memory regions: " << NumRegions << "\n";
llvm_cerr << "Bytes allocated: " << BytesUsed << "\n"; cerr << "Bytes allocated: " << BytesUsed << "\n";
} }

View File

@ -84,8 +84,8 @@ static Option *getOption(const std::string &Str) {
static void AddArgument(const char *ArgName, Option *Opt) { static void AddArgument(const char *ArgName, Option *Opt) {
if (getOption(ArgName)) { if (getOption(ArgName)) {
llvm_cerr << ProgramName << ": CommandLine Error: Argument '" cerr << ProgramName << ": CommandLine Error: Argument '"
<< ArgName << "' defined more than once!\n"; << ArgName << "' defined more than once!\n";
} else { } else {
// Add argument to the argument map! // Add argument to the argument map!
(*Options)[ArgName] = Opt; (*Options)[ArgName] = Opt;
@ -129,9 +129,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
case ValueOptional: case ValueOptional:
break; break;
default: default:
llvm_cerr << ProgramName cerr << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:" << ": Bad ValueMask flag! CommandLine usage error:"
<< Handler->getValueExpectedFlag() << "\n"; << Handler->getValueExpectedFlag() << "\n";
abort(); abort();
break; break;
} }
@ -468,8 +468,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
} }
if (Handler == 0) { if (Handler == 0) {
llvm_cerr << ProgramName << ": Unknown command line argument '" cerr << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " --help'\n"; << argv[i] << "'. Try: '" << argv[0] << " --help'\n";
ErrorParsing = true; ErrorParsing = true;
continue; continue;
} }
@ -505,18 +505,18 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
// Check and handle positional arguments now... // Check and handle positional arguments now...
if (NumPositionalRequired > PositionalVals.size()) { if (NumPositionalRequired > PositionalVals.size()) {
llvm_cerr << ProgramName cerr << ProgramName
<< ": Not enough positional command line arguments specified!\n" << ": Not enough positional command line arguments specified!\n"
<< "Must specify at least " << NumPositionalRequired << "Must specify at least " << NumPositionalRequired
<< " positional arguments: See: " << argv[0] << " --help\n"; << " positional arguments: See: " << argv[0] << " --help\n";
ErrorParsing = true; ErrorParsing = true;
} else if (!HasUnlimitedPositionals } else if (!HasUnlimitedPositionals
&& PositionalVals.size() > PositionalOpts.size()) { && PositionalVals.size() > PositionalOpts.size()) {
llvm_cerr << ProgramName cerr << ProgramName
<< ": Too many positional arguments specified!\n" << ": Too many positional arguments specified!\n"
<< "Can specify at most " << PositionalOpts.size() << "Can specify at most " << PositionalOpts.size()
<< " positional arguments: See: " << argv[0] << " --help\n"; << " positional arguments: See: " << argv[0] << " --help\n";
ErrorParsing = true; ErrorParsing = true;
} else if (ConsumeAfterOpt == 0) { } else if (ConsumeAfterOpt == 0) {
@ -617,11 +617,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
bool Option::error(std::string Message, const char *ArgName) { bool Option::error(std::string Message, const char *ArgName) {
if (ArgName == 0) ArgName = ArgStr; if (ArgName == 0) ArgName = ArgStr;
if (ArgName[0] == 0) if (ArgName[0] == 0)
llvm_cerr << HelpStr; // Be nice for positional arguments cerr << HelpStr; // Be nice for positional arguments
else else
llvm_cerr << ProgramName << ": for the -" << ArgName; cerr << ProgramName << ": for the -" << ArgName;
llvm_cerr << " option: " << Message << "\n"; cerr << " option: " << Message << "\n";
return true; return true;
} }
@ -701,8 +701,8 @@ unsigned alias::getOptionWidth() const {
// Print out the option for the alias. // Print out the option for the alias.
void alias::printOptionInfo(unsigned GlobalWidth) const { void alias::printOptionInfo(unsigned GlobalWidth) const {
unsigned L = std::strlen(ArgStr); unsigned L = std::strlen(ArgStr);
llvm_cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
<< HelpStr << "\n"; << HelpStr << "\n";
} }
@ -728,13 +728,13 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const {
// //
void basic_parser_impl::printOptionInfo(const Option &O, void basic_parser_impl::printOptionInfo(const Option &O,
unsigned GlobalWidth) const { unsigned GlobalWidth) const {
llvm_cout << " -" << O.ArgStr; cout << " -" << O.ArgStr;
if (const char *ValName = getValueName()) if (const char *ValName = getValueName())
llvm_cout << "=<" << getValueStr(O, ValName) << ">"; cout << "=<" << getValueStr(O, ValName) << ">";
llvm_cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - "
<< O.HelpStr << "\n"; << O.HelpStr << "\n";
} }
@ -850,21 +850,21 @@ void generic_parser_base::printOptionInfo(const Option &O,
unsigned GlobalWidth) const { unsigned GlobalWidth) const {
if (O.hasArgStr()) { if (O.hasArgStr()) {
unsigned L = std::strlen(O.ArgStr); unsigned L = std::strlen(O.ArgStr);
llvm_cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
<< " - " << O.HelpStr << "\n"; << " - " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8;
llvm_cout << " =" << getOption(i) << std::string(NumSpaces, ' ') cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
<< " - " << getDescription(i) << "\n"; << " - " << getDescription(i) << "\n";
} }
} else { } else {
if (O.HelpStr[0]) if (O.HelpStr[0])
llvm_cout << " " << O.HelpStr << "\n"; cout << " " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned L = std::strlen(getOption(i)); unsigned L = std::strlen(getOption(i));
llvm_cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
<< " - " << getDescription(i) << "\n"; << " - " << getDescription(i) << "\n";
} }
} }
} }
@ -917,9 +917,9 @@ public:
} }
if (ProgramOverview) if (ProgramOverview)
llvm_cout << "OVERVIEW:" << ProgramOverview << "\n"; cout << "OVERVIEW:" << ProgramOverview << "\n";
llvm_cout << "USAGE: " << ProgramName << " [options]"; cout << "USAGE: " << ProgramName << " [options]";
// Print out the positional options. // Print out the positional options.
std::vector<Option*> &PosOpts = *PositionalOptions; std::vector<Option*> &PosOpts = *PositionalOptions;
@ -929,28 +929,28 @@ public:
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) {
if (PosOpts[i]->ArgStr[0]) if (PosOpts[i]->ArgStr[0])
llvm_cout << " --" << PosOpts[i]->ArgStr; cout << " --" << PosOpts[i]->ArgStr;
llvm_cout << " " << PosOpts[i]->HelpStr; cout << " " << PosOpts[i]->HelpStr;
} }
// Print the consume after option info if it exists... // Print the consume after option info if it exists...
if (CAOpt) llvm_cout << " " << CAOpt->HelpStr; if (CAOpt) cout << " " << CAOpt->HelpStr;
llvm_cout << "\n\n"; cout << "\n\n";
// Compute the maximum argument length... // Compute the maximum argument length...
MaxArgLen = 0; MaxArgLen = 0;
for (unsigned i = 0, e = Opts.size(); i != e; ++i) for (unsigned i = 0, e = Opts.size(); i != e; ++i)
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth()); MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
llvm_cout << "OPTIONS:\n"; cout << "OPTIONS:\n";
for (unsigned i = 0, e = Opts.size(); i != e; ++i) for (unsigned i = 0, e = Opts.size(); i != e; ++i)
Opts[i].second->printOptionInfo(MaxArgLen); Opts[i].second->printOptionInfo(MaxArgLen);
// Print any extra help the user has declared. // Print any extra help the user has declared.
for (std::vector<const char *>::iterator I = MoreHelp->begin(), for (std::vector<const char *>::iterator I = MoreHelp->begin(),
E = MoreHelp->end(); I != E; ++I) E = MoreHelp->end(); I != E; ++I)
llvm_cout << *I; cout << *I;
MoreHelp->clear(); MoreHelp->clear();
// Halt the program since help information was printed // Halt the program since help information was printed
@ -982,21 +982,21 @@ public:
void operator=(bool OptionWasSpecified) { void operator=(bool OptionWasSpecified) {
if (OptionWasSpecified) { if (OptionWasSpecified) {
if (OverrideVersionPrinter == 0) { if (OverrideVersionPrinter == 0) {
llvm_cout << "Low Level Virtual Machine (http://llvm.org/):\n"; cout << "Low Level Virtual Machine (http://llvm.org/):\n";
llvm_cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
#ifdef LLVM_VERSION_INFO #ifdef LLVM_VERSION_INFO
llvm_cout << LLVM_VERSION_INFO; cout << LLVM_VERSION_INFO;
#endif #endif
llvm_cout << "\n "; cout << "\n ";
#ifndef __OPTIMIZE__ #ifndef __OPTIMIZE__
llvm_cout << "DEBUG build"; cout << "DEBUG build";
#else #else
llvm_cout << "Optimized build"; cout << "Optimized build";
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG
llvm_cout << " with assertions"; cout << " with assertions";
#endif #endif
llvm_cout << ".\n"; cout << ".\n";
Options->clear(); // Don't bother making option dtors remove from map. Options->clear(); // Don't bother making option dtors remove from map.
exit(1); exit(1);
} else { } else {

View File

@ -68,9 +68,9 @@ bool llvm::isCurrentDebugType(const char *DebugType) {
// places the std::c* I/O streams into one .cpp file and relieves the whole // places the std::c* I/O streams into one .cpp file and relieves the whole
// program from having to have hundreds of static c'tor/d'tors for them. // program from having to have hundreds of static c'tor/d'tors for them.
// //
llvm_ostream llvm::getErrorOutputStream(const char *DebugType) { OStream llvm::getErrorOutputStream(const char *DebugType) {
if (DebugFlag && isCurrentDebugType(DebugType)) if (DebugFlag && isCurrentDebugType(DebugType))
return llvm_cerr; return cerr;
else else
return llvm_null; return NullStream;
} }

View File

@ -28,9 +28,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(Filename.c_str()); args.push_back(Filename.c_str());
args.push_back(0); args.push_back(0);
llvm_cerr << "Running 'Graphviz' program... " << std::flush; cerr << "Running 'Graphviz' program... " << std::flush;
if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) { if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) {
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; cerr << "Error viewing graph: " << ErrMsg << "\n";
} }
#elif (HAVE_GV && HAVE_DOT) #elif (HAVE_GV && HAVE_DOT)
sys::Path PSFilename = Filename; sys::Path PSFilename = Filename;
@ -48,11 +48,11 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(PSFilename.c_str()); args.push_back(PSFilename.c_str());
args.push_back(0); args.push_back(0);
llvm_cerr << "Running 'dot' program... " << std::flush; cerr << "Running 'dot' program... " << std::flush;
if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) { if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) {
llvm_cerr << "Error viewing graph: '" << ErrMsg << "\n"; cerr << "Error viewing graph: '" << ErrMsg << "\n";
} else { } else {
llvm_cerr << " done. \n"; cerr << " done. \n";
sys::Path gv(LLVM_PATH_GV); sys::Path gv(LLVM_PATH_GV);
args.clear(); args.clear();
@ -62,7 +62,7 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
ErrMsg.clear(); ErrMsg.clear();
if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) { if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) {
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; cerr << "Error viewing graph: " << ErrMsg << "\n";
} }
} }
PSFilename.eraseFromDisk(); PSFilename.eraseFromDisk();
@ -73,9 +73,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(Filename.c_str()); args.push_back(Filename.c_str());
args.push_back(0); args.push_back(0);
llvm_cerr << "Running 'dotty' program... " << std::flush; cerr << "Running 'dotty' program... " << std::flush;
if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) { if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) {
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; cerr << "Error viewing graph: " << ErrMsg << "\n";
} else { } else {
#ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns
return; return;

View File

@ -26,8 +26,8 @@ void PluginLoader::operator=(const std::string &Filename) {
std::string Error; std::string Error;
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
llvm_cerr << "Error opening '" << Filename << "': " << Error cerr << "Error opening '" << Filename << "': " << Error
<< "\n -load request ignored.\n"; << "\n -load request ignored.\n";
} else { } else {
Plugins->push_back(Filename); Plugins->push_back(Filename);
} }

View File

@ -28,8 +28,8 @@ SlowOperationInformer::~SlowOperationInformer() {
if (LastPrintAmount) { if (LastPrintAmount) {
// If we have printed something, make _sure_ we print the 100% amount, and // If we have printed something, make _sure_ we print the 100% amount, and
// also print a newline. // also print a newline.
llvm_cout << std::string(LastPrintAmount, '\b') << "Progress " cout << std::string(LastPrintAmount, '\b') << "Progress "
<< OperationName << ": 100% \n"; << OperationName << ": 100% \n";
} }
} }
@ -40,7 +40,7 @@ SlowOperationInformer::~SlowOperationInformer() {
bool SlowOperationInformer::progress(unsigned Amount) { bool SlowOperationInformer::progress(unsigned Amount) {
int status = sys::AlarmStatus(); int status = sys::AlarmStatus();
if (status == -1) { if (status == -1) {
llvm_cout << "\n"; cout << "\n";
LastPrintAmount = 0; LastPrintAmount = 0;
return true; return true;
} }
@ -61,6 +61,6 @@ bool SlowOperationInformer::progress(unsigned Amount) {
OS << "% "; OS << "% ";
LastPrintAmount = OS.str().size(); LastPrintAmount = OS.str().size();
llvm_cout << ToPrint+OS.str() << std::flush; cout << ToPrint+OS.str() << std::flush;
return false; return false;
} }

View File

@ -16,6 +16,7 @@
#include <iostream> #include <iostream>
using namespace llvm; using namespace llvm;
llvm_ostream llvm::llvm_null; OStream llvm::NullStream;
llvm_ostream llvm::llvm_cout(std::cout); OStream llvm::cout(std::cout);
llvm_ostream llvm::llvm_cerr(std::cerr); OStream llvm::cerr(std::cerr);
IStream llvm::cin(std::cin);

View File

@ -23,10 +23,10 @@ bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check,
bool print_warning) { bool print_warning) {
if (stream_to_check == &std::cout && sys::Process::StandardOutIsDisplayed()) { if (stream_to_check == &std::cout && sys::Process::StandardOutIsDisplayed()) {
if (print_warning) { if (print_warning) {
llvm_cerr << "WARNING: You're attempting to print out a bytecode file.\n" cerr << "WARNING: You're attempting to print out a bytecode file.\n"
<< "This is inadvisable as it may cause display problems. If\n" << "This is inadvisable as it may cause display problems. If\n"
<< "you REALLY want to taste LLVM bytecode first-hand, you\n" << "you REALLY want to taste LLVM bytecode first-hand, you\n"
<< "can force output with the `-f' option.\n\n"; << "can force output with the `-f' option.\n\n";
} }
return true; return true;
} }

View File

@ -693,8 +693,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
I->setName(""); I->setName("");
Instruction *Res; // Result of conversion Instruction *Res; // Result of conversion
//llvm_cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I //cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I
// << "BB Before: " << BB << endl; // << "BB Before: " << BB << endl;
// Prevent I from being removed... // Prevent I from being removed...
ValueHandle IHandle(VMC, I); ValueHandle IHandle(VMC, I);

View File

@ -30,7 +30,7 @@ namespace {
HelloCounter++; HelloCounter++;
std::string fname = F.getName(); std::string fname = F.getName();
EscapeString(fname); EscapeString(fname);
llvm_cerr << "Hello: " << fname << "\n"; cerr << "Hello: " << fname << "\n";
return false; return false;
} }
}; };
@ -43,7 +43,7 @@ namespace {
HelloCounter++; HelloCounter++;
std::string fname = F.getName(); std::string fname = F.getName();
EscapeString(fname); EscapeString(fname);
llvm_cerr << "Hello: " << fname << "\n"; cerr << "Hello: " << fname << "\n";
return false; return false;
} }

View File

@ -494,17 +494,17 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) {
// Will trap. // Will trap.
} else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) { } else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
if (SI->getOperand(0) == V) { if (SI->getOperand(0) == V) {
//llvm_cerr << "NONTRAPPING USE: " << **UI; //cerr << "NONTRAPPING USE: " << **UI;
return false; // Storing the value. return false; // Storing the value.
} }
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) { } else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
if (CI->getOperand(0) != V) { if (CI->getOperand(0) != V) {
//llvm_cerr << "NONTRAPPING USE: " << **UI; //cerr << "NONTRAPPING USE: " << **UI;
return false; // Not calling the ptr return false; // Not calling the ptr
} }
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) { } else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
if (II->getOperand(0) != V) { if (II->getOperand(0) != V) {
//llvm_cerr << "NONTRAPPING USE: " << **UI; //cerr << "NONTRAPPING USE: " << **UI;
return false; // Not calling the ptr return false; // Not calling the ptr
} }
} else if (CastInst *CI = dyn_cast<CastInst>(*UI)) { } else if (CastInst *CI = dyn_cast<CastInst>(*UI)) {
@ -515,7 +515,7 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) {
isa<ConstantPointerNull>(UI->getOperand(1))) { isa<ConstantPointerNull>(UI->getOperand(1))) {
// Ignore setcc X, null // Ignore setcc X, null
} else { } else {
//llvm_cerr << "NONTRAPPING USE: " << **UI; //cerr << "NONTRAPPING USE: " << **UI;
return false; return false;
} }
return true; return true;
@ -533,7 +533,7 @@ static bool AllUsesOfLoadedValueWillTrapIfNull(GlobalVariable *GV) {
// Ignore stores to the global. // Ignore stores to the global.
} else { } else {
// We don't know or understand this user, bail out. // We don't know or understand this user, bail out.
//llvm_cerr << "UNKNOWN USER OF GLOBAL!: " << **UI; //cerr << "UNKNOWN USER OF GLOBAL!: " << **UI;
return false; return false;
} }
@ -1206,25 +1206,25 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
if (!AnalyzeGlobal(GV, GS, PHIUsers)) { if (!AnalyzeGlobal(GV, GS, PHIUsers)) {
#if 0 #if 0
llvm_cerr << "Global: " << *GV; cerr << "Global: " << *GV;
llvm_cerr << " isLoaded = " << GS.isLoaded << "\n"; cerr << " isLoaded = " << GS.isLoaded << "\n";
llvm_cerr << " StoredType = "; cerr << " StoredType = ";
switch (GS.StoredType) { switch (GS.StoredType) {
case GlobalStatus::NotStored: llvm_cerr << "NEVER STORED\n"; break; case GlobalStatus::NotStored: cerr << "NEVER STORED\n"; break;
case GlobalStatus::isInitializerStored: llvm_cerr << "INIT STORED\n"; break; case GlobalStatus::isInitializerStored: cerr << "INIT STORED\n"; break;
case GlobalStatus::isStoredOnce: llvm_cerr << "STORED ONCE\n"; break; case GlobalStatus::isStoredOnce: cerr << "STORED ONCE\n"; break;
case GlobalStatus::isStored: llvm_cerr << "stored\n"; break; case GlobalStatus::isStored: cerr << "stored\n"; break;
} }
if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue) if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue)
llvm_cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n";
if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions) if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions)
llvm_cerr << " AccessingFunction = " << GS.AccessingFunction->getName() cerr << " AccessingFunction = " << GS.AccessingFunction->getName()
<< "\n"; << "\n";
llvm_cerr << " HasMultipleAccessingFunctions = " cerr << " HasMultipleAccessingFunctions = "
<< GS.HasMultipleAccessingFunctions << "\n"; << GS.HasMultipleAccessingFunctions << "\n";
llvm_cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n";
llvm_cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n"; cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n";
llvm_cerr << "\n"; cerr << "\n";
#endif #endif
// If this is a first class global and has only one accessing function // If this is a first class global and has only one accessing function

View File

@ -74,8 +74,7 @@ void InternalizePass::LoadFile(const char *Filename) {
// Load the APIFile... // Load the APIFile...
std::ifstream In(Filename); std::ifstream In(Filename);
if (!In.good()) { if (!In.good()) {
llvm_cerr << "WARNING: Internalize couldn't load file '" << Filename cerr << "WARNING: Internalize couldn't load file '" << Filename << "'!\n";
<< "'!\n";
return; // Do not internalize anything... return; // Do not internalize anything...
} }
while (In) { while (In) {

View File

@ -47,8 +47,8 @@ ModulePass *llvm::createFunctionProfilerPass() {
bool FunctionProfiler::runOnModule(Module &M) { bool FunctionProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction(); Function *Main = M.getMainFunction();
if (Main == 0) { if (Main == 0) {
llvm_cerr << "WARNING: cannot insert function profiling into a module" cerr << "WARNING: cannot insert function profiling into a module"
<< " with no main function!\n"; << " with no main function!\n";
return false; // No main, no instrumentation! return false; // No main, no instrumentation!
} }
@ -90,8 +90,8 @@ ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); }
bool BlockProfiler::runOnModule(Module &M) { bool BlockProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction(); Function *Main = M.getMainFunction();
if (Main == 0) { if (Main == 0) {
llvm_cerr << "WARNING: cannot insert block profiling into a module" cerr << "WARNING: cannot insert block profiling into a module"
<< " with no main function!\n"; << " with no main function!\n";
return false; // No main, no instrumentation! return false; // No main, no instrumentation!
} }

View File

@ -17,6 +17,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ProfilingUtils.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -24,7 +25,6 @@
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation.h"
#include "ProfilingUtils.h"
#include <set> #include <set>
using namespace llvm; using namespace llvm;
@ -42,8 +42,8 @@ ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); }
bool EdgeProfiler::runOnModule(Module &M) { bool EdgeProfiler::runOnModule(Module &M) {
Function *Main = M.getMainFunction(); Function *Main = M.getMainFunction();
if (Main == 0) { if (Main == 0) {
llvm_cerr << "WARNING: cannot insert edge profiling into a module" cerr << "WARNING: cannot insert edge profiling into a module"
<< " with no main function!\n"; << " with no main function!\n";
return false; // No main, no instrumentation! return false; // No main, no instrumentation!
} }

View File

@ -13,6 +13,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ProfilingUtils.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -20,7 +21,6 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "ProfilingUtils.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include <set> #include <set>
using namespace llvm; using namespace llvm;
@ -61,8 +61,8 @@ static void InsertInstrumentationCall (BasicBlock *BB,
bool TraceBasicBlocks::runOnModule(Module &M) { bool TraceBasicBlocks::runOnModule(Module &M) {
Function *Main = M.getMainFunction(); Function *Main = M.getMainFunction();
if (Main == 0) { if (Main == 0) {
llvm_cerr << "WARNING: cannot insert basic-block trace instrumentation" cerr << "WARNING: cannot insert basic-block trace instrumentation"
<< " into a module with no main function!\n"; << " into a module with no main function!\n";
return false; // No main, no instrumentation! return false; // No main, no instrumentation!
} }

View File

@ -7018,8 +7018,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// If we are removing arguments to the function, emit an obnoxious warning... // If we are removing arguments to the function, emit an obnoxious warning...
if (FT->getNumParams() < NumActualArgs) if (FT->getNumParams() < NumActualArgs)
if (!FT->isVarArg()) { if (!FT->isVarArg()) {
llvm_cerr << "WARNING: While resolving call to function '" cerr << "WARNING: While resolving call to function '"
<< Callee->getName() << "' arguments were dropped!\n"; << Callee->getName() << "' arguments were dropped!\n";
} else { } else {
// Add all of the arguments in their promoted form to the arg list... // Add all of the arguments in their promoted form to the arg list...
for (unsigned i = FT->getNumParams(); i != NumActualArgs; ++i, ++AI) { for (unsigned i = FT->getNumParams(); i != NumActualArgs; ++i, ++AI) {

View File

@ -507,12 +507,12 @@ namespace {
} }
void BasedUser::dump() const { void BasedUser::dump() const {
llvm_cerr << " Base=" << *Base; cerr << " Base=" << *Base;
llvm_cerr << " Imm=" << *Imm; cerr << " Imm=" << *Imm;
if (EmittedBase) if (EmittedBase)
llvm_cerr << " EB=" << *EmittedBase; cerr << " EB=" << *EmittedBase;
llvm_cerr << " Inst: " << *Inst; cerr << " Inst: " << *Inst;
} }
Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase, Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,

View File

@ -73,8 +73,7 @@ public:
/// @param I the unhandled instruction /// @param I the unhandled instruction
void visitInstruction(Instruction &I) { void visitInstruction(Instruction &I) {
if (isa<PackedType>(I.getType())) if (isa<PackedType>(I.getType()))
llvm_cerr << "Unhandled Instruction with Packed ReturnType: " cerr << "Unhandled Instruction with Packed ReturnType: " << I << '\n';
<< I << '\n';
} }
private: private:
/// @brief Retrieves lowered values for a packed value. /// @brief Retrieves lowered values for a packed value.

View File

@ -350,7 +350,7 @@ private:
void visitInstruction(Instruction &I) { void visitInstruction(Instruction &I) {
// If a new instruction is added to LLVM that we don't handle... // If a new instruction is added to LLVM that we don't handle...
llvm_cerr << "SCCP: Don't know how to handle: " << I; cerr << "SCCP: Don't know how to handle: " << I;
markOverdefined(&I); // Just in case markOverdefined(&I); // Just in case
} }
}; };
@ -400,7 +400,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
Succs[0] = true; Succs[0] = true;
} }
} else { } else {
llvm_cerr << "SCCP: Don't know how to handle: " << TI; cerr << "SCCP: Don't know how to handle: " << TI;
Succs.assign(TI.getNumSuccessors(), true); Succs.assign(TI.getNumSuccessors(), true);
} }
} }
@ -459,7 +459,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
} }
return false; return false;
} else { } else {
llvm_cerr << "Unknown terminator instruction: " << *TI; cerr << "Unknown terminator instruction: " << *TI;
abort(); abort();
} }
} }

View File

@ -699,10 +699,10 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
} }
} }
//llvm_cerr << "NEW FUNCTION: " << *newFunction; //cerr << "NEW FUNCTION: " << *newFunction;
// verifyFunction(*newFunction); // verifyFunction(*newFunction);
// llvm_cerr << "OLD FUNCTION: " << *oldFunction; // cerr << "OLD FUNCTION: " << *oldFunction;
// verifyFunction(*oldFunction); // verifyFunction(*oldFunction);
DEBUG(if (verifyFunction(*newFunction)) abort()); DEBUG(if (verifyFunction(*newFunction)) abort());

View File

@ -96,8 +96,7 @@ bool LowerSwitch::runOnFunction(Function &F) {
// operator<< - Used for debugging purposes. // operator<< - Used for debugging purposes.
// //
llvm_ostream& operator<<(llvm_ostream &O, OStream& operator<<(OStream &O, const std::vector<LowerSwitch::Case> &C) {
const std::vector<LowerSwitch::Case> &C) {
O << "["; O << "[";
for (std::vector<LowerSwitch::Case>::const_iterator B = C.begin(), for (std::vector<LowerSwitch::Case>::const_iterator B = C.begin(),

View File

@ -829,7 +829,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
case GlobalValue::ExternalLinkage: break; case GlobalValue::ExternalLinkage: break;
case GlobalValue::GhostLinkage: case GlobalValue::GhostLinkage:
llvm_cerr << "GhostLinkage not allowed in AsmWriter!\n"; cerr << "GhostLinkage not allowed in AsmWriter!\n";
abort(); abort();
} }
@ -928,7 +928,7 @@ void AssemblyWriter::printFunction(const Function *F) {
case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
case GlobalValue::ExternalLinkage: break; case GlobalValue::ExternalLinkage: break;
case GlobalValue::GhostLinkage: case GlobalValue::GhostLinkage:
llvm_cerr << "GhostLinkage not allowed in AsmWriter!\n"; cerr << "GhostLinkage not allowed in AsmWriter!\n";
abort(); abort();
} }
@ -1328,18 +1328,18 @@ void Argument::print(std::ostream &o) const {
// Value::dump - allow easy printing of Values from the debugger. // Value::dump - allow easy printing of Values from the debugger.
// Located here because so much of the needed functionality is here. // Located here because so much of the needed functionality is here.
void Value::dump() const { print(std::cerr); llvm_cerr << '\n'; } void Value::dump() const { print(std::cerr); cerr << '\n'; }
// Type::dump - allow easy printing of Values from the debugger. // Type::dump - allow easy printing of Values from the debugger.
// Located here because so much of the needed functionality is here. // Located here because so much of the needed functionality is here.
void Type::dump() const { print(std::cerr); llvm_cerr << '\n'; } void Type::dump() const { print(std::cerr); cerr << '\n'; }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// SlotMachine Implementation // SlotMachine Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if 0 #if 0
#define SC_DEBUG(X) llvm_cerr << X #define SC_DEBUG(X) cerr << X
#else #else
#define SC_DEBUG(X) #define SC_DEBUG(X)
#endif #endif

View File

@ -11,8 +11,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Support/Compiler.h"
#include "llvm/Support/LeakDetector.h" #include "llvm/Support/LeakDetector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include "llvm/Value.h" #include "llvm/Value.h"
#include <set> #include <set>
@ -21,12 +21,12 @@ using namespace llvm;
namespace { namespace {
template <class T> template <class T>
struct VISIBILITY_HIDDEN PrinterTrait { struct VISIBILITY_HIDDEN PrinterTrait {
static void print(const T* P) { llvm_cerr << P; } static void print(const T* P) { cerr << P; }
}; };
template<> template<>
struct VISIBILITY_HIDDEN PrinterTrait<Value> { struct VISIBILITY_HIDDEN PrinterTrait<Value> {
static void print(const Value* P) { llvm_cerr << *P; } static void print(const Value* P) { cerr << *P; }
}; };
template <typename T> template <typename T>
@ -59,15 +59,14 @@ namespace {
assert(Cache == 0 && "No value should be cached anymore!"); assert(Cache == 0 && "No value should be cached anymore!");
if (!Ts.empty()) { if (!Ts.empty()) {
llvm_cerr cerr << "Leaked " << Name << " objects found: " << Message << ":\n";
<< "Leaked " << Name << " objects found: " << Message << ":\n";
for (typename std::set<const T*>::iterator I = Ts.begin(), for (typename std::set<const T*>::iterator I = Ts.begin(),
E = Ts.end(); I != E; ++I) { E = Ts.end(); I != E; ++I) {
llvm_cerr << "\t"; cerr << "\t";
PrinterTrait<T>::print(*I); PrinterTrait<T>::print(*I);
llvm_cerr << "\n"; cerr << "\n";
} }
llvm_cerr << '\n'; cerr << '\n';
return true; return true;
} }
@ -123,8 +122,8 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) {
// use non-short-circuit version so that both checks are performed // use non-short-circuit version so that both checks are performed
if (getObjects().hasGarbage(Message) | if (getObjects().hasGarbage(Message) |
getLLVMObjects().hasGarbage(Message)) getLLVMObjects().hasGarbage(Message))
llvm_cerr << "\nThis is probably because you removed an object, but didn't " cerr << "\nThis is probably because you removed an object, but didn't "
<< "delete it. Please check your code for memory leaks.\n"; << "delete it. Please check your code for memory leaks.\n";
// Clear out results so we don't get duplicate warnings on // Clear out results so we don't get duplicate warnings on
// next call... // next call...

View File

@ -442,7 +442,7 @@ bool FunctionPassManager_New::runOnModule(Module &M) {
bool FunctionPassManager_New::run(Function &F) { bool FunctionPassManager_New::run(Function &F) {
std::string errstr; std::string errstr;
if (MP->materializeFunction(&F, &errstr)) { if (MP->materializeFunction(&F, &errstr)) {
llvm_cerr << "Error reading bytecode file: " << errstr << "\n"; cerr << "Error reading bytecode file: " << errstr << "\n";
abort(); abort();
} }
return FPM->runOnFunction(F); return FPM->runOnFunction(F);

View File

@ -66,7 +66,7 @@ Type* TypeSymbolTable::erase(iterator Entry) {
#if DEBUG_SYMBOL_TABLE #if DEBUG_SYMBOL_TABLE
dump(); dump();
llvm_cerr << " Removing Value: " << Result->getName() << "\n"; cerr << " Removing Value: " << Result->getName() << "\n";
#endif #endif
tmap.erase(Entry); tmap.erase(Entry);
@ -75,7 +75,7 @@ Type* TypeSymbolTable::erase(iterator Entry) {
// list... // list...
if (Result->isAbstract()) { if (Result->isAbstract()) {
#if DEBUG_ABSTYPE #if DEBUG_ABSTYPE
llvm_cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n"; cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n";
#endif #endif
cast<DerivedType>(Result)->removeAbstractTypeUser(this); cast<DerivedType>(Result)->removeAbstractTypeUser(this);
} }
@ -95,8 +95,8 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
#if DEBUG_SYMBOL_TABLE #if DEBUG_SYMBOL_TABLE
dump(); dump();
llvm_cerr << " Inserting type: " << UniqueName << ": " cerr << " Inserting type: " << UniqueName << ": "
<< T->getDescription() << "\n"; << T->getDescription() << "\n";
#endif #endif
// Insert the tmap entry // Insert the tmap entry
@ -106,7 +106,7 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
if (T->isAbstract()) { if (T->isAbstract()) {
cast<DerivedType>(T)->addAbstractTypeUser(this); cast<DerivedType>(T)->addAbstractTypeUser(this);
#if DEBUG_ABSTYPE #if DEBUG_ABSTYPE
llvm_cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; cerr << "Added abstract type to ST: " << T->getDescription() << "\n";
#endif #endif
} }
} }
@ -152,14 +152,14 @@ void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
for (iterator I = begin(), E = end(); I != E; ++I) { for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->second == (Type*)OldType) { // FIXME when Types aren't const. if (I->second == (Type*)OldType) { // FIXME when Types aren't const.
#if DEBUG_ABSTYPE #if DEBUG_ABSTYPE
llvm_cerr << "Removing type " << OldType->getDescription() << "\n"; cerr << "Removing type " << OldType->getDescription() << "\n";
#endif #endif
OldType->removeAbstractTypeUser(this); OldType->removeAbstractTypeUser(this);
I->second = (Type*)NewType; // TODO FIXME when types aren't const I->second = (Type*)NewType; // TODO FIXME when types aren't const
if (NewType->isAbstract()) { if (NewType->isAbstract()) {
#if DEBUG_ABSTYPE #if DEBUG_ABSTYPE
llvm_cerr << "Added type " << NewType->getDescription() << "\n"; cerr << "Added type " << NewType->getDescription() << "\n";
#endif #endif
cast<DerivedType>(NewType)->addAbstractTypeUser(this); cast<DerivedType>(NewType)->addAbstractTypeUser(this);
} }
@ -179,13 +179,13 @@ void TypeSymbolTable::typeBecameConcrete(const DerivedType *AbsTy) {
} }
static void DumpTypes(const std::pair<const std::string, const Type*>& T ) { static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
llvm_cerr << " '" << T.first << "' = "; cerr << " '" << T.first << "' = ";
T.second->dump(); T.second->dump();
llvm_cerr << "\n"; cerr << "\n";
} }
void TypeSymbolTable::dump() const { void TypeSymbolTable::dump() const {
llvm_cerr << "TypeSymbolPlane: "; cerr << "TypeSymbolPlane: ";
for_each(tmap.begin(), tmap.end(), DumpTypes); for_each(tmap.begin(), tmap.end(), DumpTypes);
} }

View File

@ -60,7 +60,6 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include <algorithm> #include <algorithm>
#include <sstream>
#include <cstdarg> #include <cstdarg>
using namespace llvm; using namespace llvm;
@ -156,11 +155,11 @@ namespace { // Anonymous namespace for class
switch (action) { switch (action) {
case AbortProcessAction: case AbortProcessAction:
msgs << "compilation aborted!\n"; msgs << "compilation aborted!\n";
llvm_cerr << msgs.str(); cerr << msgs.str();
abort(); abort();
case PrintMessageAction: case PrintMessageAction:
msgs << "verification continues.\n"; msgs << "verification continues.\n";
llvm_cerr << msgs.str(); cerr << msgs.str();
return false; return false;
case ReturnStatusAction: case ReturnStatusAction:
msgs << "compilation terminated.\n"; msgs << "compilation terminated.\n";

View File

@ -115,7 +115,7 @@ int main(int argc, char **argv)
} }
if (DumpAsm) if (DumpAsm)
llvm_cerr << "Here's the assembly:" << M.get(); cerr << "Here's the assembly:" << M.get();
if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "") { // Specified an output filename?
if (OutputFilename != "-") { // Not stdout? if (OutputFilename != "-") { // Not stdout?
@ -163,15 +163,15 @@ int main(int argc, char **argv)
throw std::string("error opening ") + OutputFilename + "!"; throw std::string("error opening ") + OutputFilename + "!";
} }
llvm_ostream L(*Out); OStream L(*Out);
WriteBytecodeToFile(M.get(), L); WriteBytecodeToFile(M.get(), L);
} catch (const ParseError &E) { } catch (const ParseError &E) {
llvm_cerr << argv[0] << ": " << E.getMessage() << "\n"; cerr << argv[0] << ": " << E.getMessage() << "\n";
return 1; return 1;
} }
} }
catch (const std::string& msg ) { catch (const std::string& msg ) {
llvm_cerr << argv[0] << ": " << msg << "\n"; cerr << argv[0] << ": " << msg << "\n";
return 1; return 1;
} }

View File

@ -56,7 +56,7 @@ bool BugDriver::writeProgramToFile(const std::string &Filename,
std::ofstream Out(Filename.c_str(), io_mode); std::ofstream Out(Filename.c_str(), io_mode);
if (!Out.good()) return true; if (!Out.good()) return true;
try { try {
llvm_ostream L(Out); OStream L(Out);
WriteBytecodeToFile(M ? M : Program, L, /*compression=*/true); WriteBytecodeToFile(M ? M : Program, L, /*compression=*/true);
} catch (...) { } catch (...) {
return true; return true;
@ -74,15 +74,15 @@ void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) {
// //
std::string Filename = "bugpoint-" + ID + ".bc"; std::string Filename = "bugpoint-" + ID + ".bc";
if (writeProgramToFile(Filename)) { if (writeProgramToFile(Filename)) {
llvm_cerr << "Error opening file '" << Filename << "' for writing!\n"; cerr << "Error opening file '" << Filename << "' for writing!\n";
return; return;
} }
llvm_cout << "Emitted bytecode to '" << Filename << "'\n"; cout << "Emitted bytecode to '" << Filename << "'\n";
if (NoFlyer || PassesToRun.empty()) return; if (NoFlyer || PassesToRun.empty()) return;
llvm_cout << "\n*** You can reproduce the problem with: "; cout << "\n*** You can reproduce the problem with: ";
llvm_cout << "opt " << Filename << " "; cout << "opt " << Filename << " ";
llvm_cout << getPassesString(PassesToRun) << "\n"; cout << getPassesString(PassesToRun) << "\n";
} }
int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) { int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
@ -91,7 +91,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
std::ios::binary; std::ios::binary;
std::ofstream OutFile(ChildOutput.c_str(), io_mode); std::ofstream OutFile(ChildOutput.c_str(), io_mode);
if (!OutFile.good()) { if (!OutFile.good()) {
llvm_cerr << "Error opening bytecode file: " << ChildOutput << "\n"; cerr << "Error opening bytecode file: " << ChildOutput << "\n";
return 1; return 1;
} }
@ -103,14 +103,13 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
if (Passes[i]->getNormalCtor()) if (Passes[i]->getNormalCtor())
PM.add(Passes[i]->getNormalCtor()()); PM.add(Passes[i]->getNormalCtor()());
else else
llvm_cerr << "Cannot create pass yet: " << Passes[i]->getPassName() cerr << "Cannot create pass yet: " << Passes[i]->getPassName() << "\n";
<< "\n";
} }
// Check that the module is well formed on completion of optimization // Check that the module is well formed on completion of optimization
PM.add(createVerifierPass()); PM.add(createVerifierPass());
// Write bytecode out to disk as the last step... // Write bytecode out to disk as the last step...
llvm_ostream L(OutFile); OStream L(OutFile);
PM.add(new WriteBytecodePass(&L)); PM.add(new WriteBytecodePass(&L));
// Run all queued passes. // Run all queued passes.
@ -131,12 +130,12 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
std::string &OutputFilename, bool DeleteOutput, std::string &OutputFilename, bool DeleteOutput,
bool Quiet) const { bool Quiet) const {
// setup the output file name // setup the output file name
llvm_cout << std::flush; cout << std::flush;
sys::Path uniqueFilename("bugpoint-output.bc"); sys::Path uniqueFilename("bugpoint-output.bc");
std::string ErrMsg; std::string ErrMsg;
if (uniqueFilename.makeUnique(true, &ErrMsg)) { if (uniqueFilename.makeUnique(true, &ErrMsg)) {
llvm_cerr << getToolName() << ": Error making unique filename: " cerr << getToolName() << ": Error making unique filename: "
<< ErrMsg << "\n"; << ErrMsg << "\n";
return(1); return(1);
} }
OutputFilename = uniqueFilename.toString(); OutputFilename = uniqueFilename.toString();
@ -144,18 +143,18 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
// set up the input file name // set up the input file name
sys::Path inputFilename("bugpoint-input.bc"); sys::Path inputFilename("bugpoint-input.bc");
if (inputFilename.makeUnique(true, &ErrMsg)) { if (inputFilename.makeUnique(true, &ErrMsg)) {
llvm_cerr << getToolName() << ": Error making unique filename: " cerr << getToolName() << ": Error making unique filename: "
<< ErrMsg << "\n"; << ErrMsg << "\n";
return(1); return(1);
} }
std::ios::openmode io_mode = std::ios::out | std::ios::trunc | std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
std::ios::binary; std::ios::binary;
std::ofstream InFile(inputFilename.c_str(), io_mode); std::ofstream InFile(inputFilename.c_str(), io_mode);
if (!InFile.good()) { if (!InFile.good()) {
llvm_cerr << "Error opening bytecode file: " << inputFilename << "\n"; cerr << "Error opening bytecode file: " << inputFilename << "\n";
return(1); return(1);
} }
llvm_ostream L(InFile); OStream L(InFile);
WriteBytecodeToFile(Program,L,false); WriteBytecodeToFile(Program,L,false);
InFile.close(); InFile.close();
@ -207,17 +206,17 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
if (!Quiet) { if (!Quiet) {
if (result == 0) if (result == 0)
llvm_cout << "Success!\n"; cout << "Success!\n";
else if (result > 0) else if (result > 0)
llvm_cout << "Exited with error code '" << result << "'\n"; cout << "Exited with error code '" << result << "'\n";
else if (result < 0) { else if (result < 0) {
if (result == -1) if (result == -1)
llvm_cout << "Execute failed: " << ErrMsg << "\n"; cout << "Execute failed: " << ErrMsg << "\n";
else else
llvm_cout << "Crashed with signal #" << abs(result) << "\n"; cout << "Crashed with signal #" << abs(result) << "\n";
} }
if (result & 0x01000000) if (result & 0x01000000)
llvm_cout << "Dumped core\n"; cout << "Dumped core\n";
} }
// Was the child successful? // Was the child successful?
@ -235,8 +234,8 @@ Module *BugDriver::runPassesOn(Module *M,
std::string BytecodeResult; std::string BytecodeResult;
if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) {
if (AutoDebugCrashes) { if (AutoDebugCrashes) {
llvm_cerr << " Error running this sequence of passes" cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
delete OldProgram; delete OldProgram;
EmitProgressBytecode("pass-error", false); EmitProgressBytecode("pass-error", false);
exit(debugOptimizerCrash()); exit(debugOptimizerCrash());
@ -250,8 +249,8 @@ Module *BugDriver::runPassesOn(Module *M,
Module *Ret = ParseInputFile(BytecodeResult); Module *Ret = ParseInputFile(BytecodeResult);
if (Ret == 0) { if (Ret == 0) {
llvm_cerr << getToolName() << ": Error reading bytecode file '" cerr << getToolName() << ": Error reading bytecode file '"
<< BytecodeResult << "'!\n"; << BytecodeResult << "'!\n";
exit(1); exit(1);
} }
sys::Path(BytecodeResult).eraseFromDisk(); // No longer need the file on disk sys::Path(BytecodeResult).eraseFromDisk(); // No longer need the file on disk

Some files were not shown because too many files have changed in this diff Show More