[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.34 -> 1.35 --- Log message: Initialize variable to null so it has a value in the off chance that a memory buffer couldn't be allocated. --- Diffs of the changes: (+1 -1) llvm-prof.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.34 llvm/tools/llvm-prof/llvm-prof.cpp:1.35 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.34 Sun May 6 18:45:49 2007 +++ llvm/tools/llvm-prof/llvm-prof.cpp Mon May 7 13:50:07 2007 @@ -117,7 +117,7 @@ // Read in the bytecode file... std::string ErrorMessage; -Module *M; +Module *M = 0; if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BytecodeFile, &ErrorMessage)) { M = ParseBitcodeFile(Buffer, &ErrorMessage); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.33 -> 1.34 --- Log message: use the new MemoryBuffer interfaces to simplify error reporting in clients. --- Diffs of the changes: (+4 -6) llvm-prof.cpp | 10 -- 1 files changed, 4 insertions(+), 6 deletions(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.33 llvm/tools/llvm-prof/llvm-prof.cpp:1.34 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.33 Sun May 6 04:29:57 2007 +++ llvm/tools/llvm-prof/llvm-prof.cpp Sun May 6 18:45:49 2007 @@ -118,13 +118,11 @@ // Read in the bytecode file... std::string ErrorMessage; Module *M; -MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0], -BytecodeFile.size()); -if (Buffer == 0) - ErrorMessage = "Error reading file '" + BytecodeFile + "'"; -else +if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BytecodeFile, +&ErrorMessage)) { M = ParseBitcodeFile(Buffer, &ErrorMessage); -delete Buffer; + delete Buffer; +} if (M == 0) { std::cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage << "\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.30 -> 1.31 --- Log message: Unbreak VC++ build. --- Diffs of the changes: (+1 -0) llvm-prof.cpp |1 + 1 files changed, 1 insertion(+) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.30 llvm/tools/llvm-prof/llvm-prof.cpp:1.31 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.30 Wed Feb 7 15:41:02 2007 +++ llvm/tools/llvm-prof/llvm-prof.cpp Sun Mar 4 18:00:42 2007 @@ -21,6 +21,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/System/Signals.h" +#include #include #include #include ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.29 -> 1.30 --- Log message: push bytecode decompressor out through APIs. Now the bytecode reader api's look like this: ModuleProvider *getBytecodeModuleProvider( const std::string &Filename, ///< Name of file to be read BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer, std::string* ErrMsg = 0, ///< Optional error message holder BytecodeHandler* H = 0///< Optional handler for reader events ); This is ugly, but allows a client to say: getBytecodeModuleProvider("foo", 0); If they do this, there is no dependency on the compression libraries, saving codesize. --- Diffs of the changes: (+3 -1) llvm-prof.cpp |4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.29 llvm/tools/llvm-prof/llvm-prof.cpp:1.30 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.29 Tue Dec 5 19:18:01 2006 +++ llvm/tools/llvm-prof/llvm-prof.cpp Wed Feb 7 15:41:02 2007 @@ -115,7 +115,9 @@ // Read in the bytecode file... std::string ErrorMessage; -Module *M = ParseBytecodeFile(BytecodeFile, &ErrorMessage); +Module *M = ParseBytecodeFile(BytecodeFile, + Compressor::decompressToNewBuffer, + &ErrorMessage); if (M == 0) { std::cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage << "\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.28 -> 1.29 --- Log message: make all llvm tools call llvm_shutdown when they exit, static'ify some stuff. With this change, I can now move -stats to print when llvm_shutdown is called. --- Diffs of the changes: (+2 -0) llvm-prof.cpp |2 ++ 1 files changed, 2 insertions(+) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.28 llvm/tools/llvm-prof/llvm-prof.cpp:1.29 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.28 Wed May 24 14:21:12 2006 +++ llvm/tools/llvm-prof/llvm-prof.cpp Tue Dec 5 19:18:01 2006 @@ -19,6 +19,7 @@ #include "llvm/Analysis/ProfileInfoLoader.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/System/Signals.h" #include #include @@ -107,6 +108,7 @@ int main(int argc, char **argv) { + llvm_shutdown_obj X; // Call llvm_shutdown() on exit. try { cl::ParseCommandLineOptions(argc, argv, " llvm profile dump decoder\n"); sys::PrintStackTraceOnErrorSignal(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.27 -> 1.28 --- Log message: For PR786: http://llvm.cs.uiuc.edu/PR786 : Minor tweaks in public headers and a few .cpp files so that LLVM can build successfully with -pedantic and projects using LLVM with -pedantic don't get warnings from LLVM. There's still more -pedantic warnings to fix. --- Diffs of the changes: (+1 -1) llvm-prof.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.27 llvm/tools/llvm-prof/llvm-prof.cpp:1.28 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.27 Fri Dec 30 03:07:29 2005 +++ llvm/tools/llvm-prof/llvm-prof.cpp Wed May 24 14:21:12 2006 @@ -139,7 +139,7 @@ sort(FunctionCounts.begin(), FunctionCounts.end(), PairSecondSortReverse()); -unsigned long long TotalExecutions = 0; +uint64_t TotalExecutions = 0; for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) TotalExecutions += FunctionCounts[i].second; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.26 -> 1.27 --- Log message: Revert removal of std:: prefixes and addtion of "using namespace std;". This violates the LLVM coding standards. --- Diffs of the changes: (+55 -55) llvm-prof.cpp | 110 +- 1 files changed, 55 insertions(+), 55 deletions(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.26 llvm/tools/llvm-prof/llvm-prof.cpp:1.27 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.26 Thu Dec 29 15:13:45 2005 +++ llvm/tools/llvm-prof/llvm-prof.cpp Fri Dec 30 03:07:29 2005 @@ -26,14 +26,13 @@ #include using namespace llvm; -using namespace std; namespace { - cl::opt + cl::opt BytecodeFile(cl::Positional, cl::desc(""), cl::Required); - cl::opt + cl::opt ProfileDataFile(cl::Positional, cl::desc(""), cl::Optional, cl::init("llvmprof.out")); @@ -50,31 +49,31 @@ // PairSecondSort - A sorting predicate to sort by the second element of a pair. template struct PairSecondSortReverse - : public binary_function, -pair, bool> { - bool operator()(const pair &LHS, - const pair &RHS) const { + : public std::binary_function, +std::pair, bool> { + bool operator()(const std::pair &LHS, + const std::pair &RHS) const { return LHS.second > RHS.second; } }; namespace { class ProfileAnnotator : public AssemblyAnnotationWriter { -map &FuncFreqs; -map &BlockFreqs; -map &EdgeFreqs; +std::map &FuncFreqs; +std::map &BlockFreqs; +std::map &EdgeFreqs; public: -ProfileAnnotator(map &FF, - map &BF, - map &EF) +ProfileAnnotator(std::map &FF, + std::map &BF, + std::map &EF) : FuncFreqs(FF), BlockFreqs(BF), EdgeFreqs(EF) {} -virtual void emitFunctionAnnot(const Function *F, ostream &OS) { +virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) { OS << ";;; %" << F->getName() << " called " << FuncFreqs[F] << " times.\n;;;\n"; } virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, - ostream &OS) { + std::ostream &OS) { if (BlockFreqs.empty()) return; if (unsigned Count = BlockFreqs[BB]) OS << "\t;;; Basic block executed " << Count << " times.\n"; @@ -82,18 +81,18 @@ OS << "\t;;; Never executed!\n"; } -virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, ostream &OS){ +virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){ if (EdgeFreqs.empty()) return; // Figure out how many times each successor executed. - vector > SuccCounts; + std::vector > SuccCounts; const TerminatorInst *TI = BB->getTerminator(); - map::iterator I = -EdgeFreqs.lower_bound(make_pair(const_cast(BB), 0U)); + std::map::iterator I = +EdgeFreqs.lower_bound(std::make_pair(const_cast(BB), 0U)); for (; I != EdgeFreqs.end() && I->first.first == BB; ++I) if (I->second) - SuccCounts.push_back(make_pair(TI->getSuccessor(I->first.second), + SuccCounts.push_back(std::make_pair(TI->getSuccessor(I->first.second), I->second)); if (!SuccCounts.empty()) { OS << "\t;;; Out-edge counts:"; @@ -113,25 +112,26 @@ sys::PrintStackTraceOnErrorSignal(); // Read in the bytecode file... -string ErrorMessage; +std::string ErrorMessage; Module *M = ParseBytecodeFile(BytecodeFile, &ErrorMessage); if (M == 0) { - cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage << "\n"; + std::cerr << argv[0] << ": " << BytecodeFile << ": " +<< ErrorMessage << "\n"; return 1; } // Read the profiling information ProfileInfoLoader PI(argv[0], ProfileDataFile, *M); -map FuncFreqs; -map BlockFreqs; -map EdgeFreqs; +std::map FuncFreqs; +std::map BlockFreqs; +std::map EdgeFreqs; // Output a report. Eventually, there will be multiple reports selectable on // the command line, for now, just keep things simple. // Emit the most frequent function table... -vector > FunctionCounts; +std::vector > FunctionCounts; PI.getFunctionCounts(FunctionCounts); FuncFreqs.insert(FunctionCounts.begin(), FunctionCounts.end()); @@ -143,41 +143,41 @@ for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) TotalExecutions += FunctionCounts[i].second; -cout << "===" << string(73, '-') << "===\n" +std::cout << "===" << std::string(73, '-') << "===\n" << "LLVM profiling output for execution"; -if (PI.getNumExecutions() !
[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp
Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.25 -> 1.26 --- Log message: General cleanup: 1. Don't mix C++ and C standard I/O, convert to C++ iostreams 2. Wrap long lines 3. use the std namespace to simplify/shorten the code --- Diffs of the changes: (+66 -61) llvm-prof.cpp | 127 ++ 1 files changed, 66 insertions(+), 61 deletions(-) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.25 llvm/tools/llvm-prof/llvm-prof.cpp:1.26 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.25 Thu Apr 21 18:59:42 2005 +++ llvm/tools/llvm-prof/llvm-prof.cpp Thu Dec 29 15:13:45 2005 @@ -20,19 +20,20 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" -#include #include +#include #include #include using namespace llvm; +using namespace std; namespace { - cl::opt + cl::opt BytecodeFile(cl::Positional, cl::desc(""), cl::Required); - cl::opt + cl::opt ProfileDataFile(cl::Positional, cl::desc(""), cl::Optional, cl::init("llvmprof.out")); @@ -49,31 +50,31 @@ // PairSecondSort - A sorting predicate to sort by the second element of a pair. template struct PairSecondSortReverse - : public std::binary_function, -std::pair, bool> { - bool operator()(const std::pair &LHS, - const std::pair &RHS) const { + : public binary_function, +pair, bool> { + bool operator()(const pair &LHS, + const pair &RHS) const { return LHS.second > RHS.second; } }; namespace { class ProfileAnnotator : public AssemblyAnnotationWriter { -std::map &FuncFreqs; -std::map &BlockFreqs; -std::map &EdgeFreqs; +map &FuncFreqs; +map &BlockFreqs; +map &EdgeFreqs; public: -ProfileAnnotator(std::map &FF, - std::map &BF, - std::map &EF) +ProfileAnnotator(map &FF, + map &BF, + map &EF) : FuncFreqs(FF), BlockFreqs(BF), EdgeFreqs(EF) {} -virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) { +virtual void emitFunctionAnnot(const Function *F, ostream &OS) { OS << ";;; %" << F->getName() << " called " << FuncFreqs[F] << " times.\n;;;\n"; } virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, - std::ostream &OS) { + ostream &OS) { if (BlockFreqs.empty()) return; if (unsigned Count = BlockFreqs[BB]) OS << "\t;;; Basic block executed " << Count << " times.\n"; @@ -81,18 +82,18 @@ OS << "\t;;; Never executed!\n"; } -virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){ +virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, ostream &OS){ if (EdgeFreqs.empty()) return; // Figure out how many times each successor executed. - std::vector > SuccCounts; + vector > SuccCounts; const TerminatorInst *TI = BB->getTerminator(); - std::map::iterator I = -EdgeFreqs.lower_bound(std::make_pair(const_cast(BB), 0U)); + map::iterator I = +EdgeFreqs.lower_bound(make_pair(const_cast(BB), 0U)); for (; I != EdgeFreqs.end() && I->first.first == BB; ++I) if (I->second) - SuccCounts.push_back(std::make_pair(TI->getSuccessor(I->first.second), + SuccCounts.push_back(make_pair(TI->getSuccessor(I->first.second), I->second)); if (!SuccCounts.empty()) { OS << "\t;;; Out-edge counts:"; @@ -112,70 +113,71 @@ sys::PrintStackTraceOnErrorSignal(); // Read in the bytecode file... -std::string ErrorMessage; +string ErrorMessage; Module *M = ParseBytecodeFile(BytecodeFile, &ErrorMessage); if (M == 0) { - std::cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage -<< "\n"; + cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage << "\n"; return 1; } // Read the profiling information ProfileInfoLoader PI(argv[0], ProfileDataFile, *M); -std::map FuncFreqs; -std::map BlockFreqs; -std::map EdgeFreqs; +map FuncFreqs; +map BlockFreqs; +map EdgeFreqs; -// Output a report. Eventually, there will be multiple reports selectable on +// Output a report. Eventually, there will be multiple reports selectable on // the command line, for now, just keep things simple. // Emit the most frequent function table... -std::vector > FunctionCounts; +vector > FunctionCounts; PI.getFunctionCounts(FunctionCounts); FuncFreqs.insert(FunctionCounts.begin(), FunctionCounts.end()); // Sort by the frequency, backwards. -std::sort(