From c9008c5cc7113ea4c3a262e346c0dfcdbca12ae6 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 5 Aug 2009 21:51:16 +0000 Subject: Make block and function count available via ProfileInfo. - Part of optimal static profiling patch sequence by Andreas Neustifter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78247 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-prof/llvm-prof.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tools/llvm-prof') diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp index 64fe451..d3971d3 100644 --- a/tools/llvm-prof/llvm-prof.cpp +++ b/tools/llvm-prof/llvm-prof.cpp @@ -142,9 +142,8 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) { std::vector > FunctionCounts; std::vector > Counts; for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) { - unsigned w = PI.getExecutionCount(FI); - if (w != (unsigned) -1) - FunctionCounts.push_back(std::make_pair(FI,PI.getExecutionCount(FI))); + if (FI->isDeclaration()) continue; + FunctionCounts.push_back(std::make_pair(FI,PI.getExecutionCount(FI))); for (Function::iterator BB = FI->begin(), BBE = FI->end(); BB != BBE; ++BB) { Counts.push_back(std::make_pair(BB,PI.getExecutionCount(BB))); @@ -209,7 +208,7 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) { if (Counts[i].second == 0) break; Function *F = Counts[i].first->getParent(); std::cout << std::setw(3) << i+1 << ". " - << std::setw(5) << std::setprecision(2) + << std::setw(5) << std::setprecision(3) << Counts[i].second/(double)TotalExecutions*100 << "% " << std::setw(5) << Counts[i].second << "/" << TotalExecutions << "\t" -- cgit v1.1