#include <map>
#include <set>
+using namespace llvm;
+
namespace {
cl::opt<std::string>
BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"),
cl::desc("Print LLVM code with frequency annotations"));
cl::alias PrintAnnotated2("A", cl::desc("Alias for --annotated-llvm"),
cl::aliasopt(PrintAnnotatedLLVM));
+ cl::opt<bool>
+ PrintAllCode("print-all-code",
+ cl::desc("Print annotated code for the entire program"));
}
// PairSecondSort - A sorting predicate to sort by the second element of a pair.
unsigned BlocksToPrint = Counts.size();
if (BlocksToPrint > 20) BlocksToPrint = 20;
for (unsigned i = 0; i != BlocksToPrint; ++i) {
+ if (Counts[i].second == 0) break;
Function *F = Counts[i].first->getParent();
printf("%3d. %5.2f%% %5u/%llu\t%s() - %s\n", i+1,
Counts[i].second/(double)TotalExecutions*100,
BlockFreqs.insert(Counts.begin(), Counts.end());
}
- if (PrintAnnotatedLLVM) {
+ if (PrintAnnotatedLLVM || PrintAllCode) {
std::cout << "\n===" << std::string(73, '-') << "===\n";
std::cout << "Annotated LLVM code for the module:\n\n";
- if (FunctionsToPrint.empty())
- for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
- FunctionsToPrint.insert(I);
-
ProfileAnnotator PA(FuncFreqs, BlockFreqs);
- for (std::set<Function*>::iterator I = FunctionsToPrint.begin(),
- E = FunctionsToPrint.end(); I != E; ++I)
- (*I)->print(std::cout, &PA);
+ if (FunctionsToPrint.empty() || PrintAllCode)
+ M->print(std::cout, &PA);
+ else
+ // Print just a subset of the functions...
+ for (std::set<Function*>::iterator I = FunctionsToPrint.begin(),
+ E = FunctionsToPrint.end(); I != E; ++I)
+ (*I)->print(std::cout, &PA);
}
return 0;