diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-08 18:20:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-08 18:20:18 +0000 |
commit | 01945c17398ec5f2934f4a166a231e3aea17831b (patch) | |
tree | 6c290637838dab38837757876b00773f409b807e /lib | |
parent | fd755f7c7ca7df21befc94698502ad07b4cf8280 (diff) | |
download | external_llvm-01945c17398ec5f2934f4a166a231e3aea17831b.zip external_llvm-01945c17398ec5f2934f4a166a231e3aea17831b.tar.gz external_llvm-01945c17398ec5f2934f4a166a231e3aea17831b.tar.bz2 |
Add initial support for reading edge counts. This will be improved to enable
translation of edge counts into block/function counts when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ProfileInfoLoader.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Analysis/ProfileInfoLoader.cpp b/lib/Analysis/ProfileInfoLoader.cpp index 39d2b6e..cef0897 100644 --- a/lib/Analysis/ProfileInfoLoader.cpp +++ b/lib/Analysis/ProfileInfoLoader.cpp @@ -14,6 +14,7 @@ #include "llvm/Analysis/ProfileInfoLoader.h" #include "llvm/Module.h" +#include "llvm/InstrTypes.h" #include <cstdio> using namespace llvm; @@ -21,6 +22,7 @@ enum ProfilingType { ArgumentInfo = 1, // The command line argument block FunctionInfo = 2, // Function profiling information BlockInfo = 3, // Block profiling information + EdgeInfo = 4, // Edge profiling information }; // ByteSwap - Byteswap 'Var' if 'Really' is true. @@ -122,6 +124,10 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, ReadProfilingBlock(ToolName, F, ShouldByteSwap, BlockCounts); break; + case EdgeInfo: + ReadProfilingBlock(ToolName, F, ShouldByteSwap, EdgeCounts); + break; + default: std::cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n"; exit(1); @@ -178,3 +184,26 @@ void ProfileInfoLoader::getBlockCounts(std::vector<std::pair<BasicBlock*, return; } } + +// getEdgeCounts - This method is used by consumers of edge counting +// information. If we do not directly have edge count information, we compute +// it from other, more refined, types of profile information. +// +void ProfileInfoLoader::getEdgeCounts(std::vector<std::pair<Edge, + unsigned> > &Counts) { + if (EdgeCounts.empty()) { + std::cerr << "Edge counts not available, and no synthesis " + << "is implemented yet!\n"; + return; + } + + unsigned Counter = 0; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + for (unsigned i = 0, e = BB->getTerminator()->getNumSuccessors(); + i != e; ++i) { + Counts.push_back(std::make_pair(Edge(BB, i), EdgeCounts[Counter++])); + if (Counter == EdgeCounts.size()) + return; + } +} |