diff options
author | Andreas Neustifter <astifter-llvm@gmx.at> | 2009-09-03 08:41:05 +0000 |
---|---|---|
committer | Andreas Neustifter <astifter-llvm@gmx.at> | 2009-09-03 08:41:05 +0000 |
commit | b68e921c25a949393589120283073a35cdcb1f08 (patch) | |
tree | 8840fa72b4f7cc4cf855dd5473b13af259738dea /llvm/lib/Analysis | |
parent | f563ac919b75dbe8f2879a786df1a0a366e1358c (diff) | |
download | bcm5719-llvm-b68e921c25a949393589120283073a35cdcb1f08.tar.gz bcm5719-llvm-b68e921c25a949393589120283073a35cdcb1f08.zip |
Code Cleanup.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090831/086139.html)
llvm-svn: 80909
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ProfileInfoLoader.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/ProfileInfoLoader.cpp b/llvm/lib/Analysis/ProfileInfoLoader.cpp index dfb79ff875c..7ecfed0b107 100644 --- a/llvm/lib/Analysis/ProfileInfoLoader.cpp +++ b/llvm/lib/Analysis/ProfileInfoLoader.cpp @@ -32,6 +32,13 @@ static inline unsigned ByteSwap(unsigned Var, bool Really) { ((Var & (255<<24)) >> 24); } +static const unsigned AddCounts(unsigned A, unsigned B) { + // If either value is undefined, use the other. + if (A == ~0U) return B; + if (B == ~0U) return A; + return A + B; +} + static void ReadProfilingBlock(const char *ToolName, FILE *F, bool ShouldByteSwap, std::vector<unsigned> &Data) { @@ -62,25 +69,11 @@ static void ReadProfilingBlock(const char *ToolName, FILE *F, // Accumulate the data we just read into the data. if (!ShouldByteSwap) { for (unsigned i = 0; i != NumEntries; ++i) { - unsigned data = TempSpace[i]; - if (data != (unsigned)-1) { // only load data if its not MissingVal - if (Data[i] == (unsigned)-1) { - Data[i] = data; // if data is still initialised - } else { - Data[i] += data; - } - } + Data[i] = AddCounts(TempSpace[i], Data[i]); } } else { for (unsigned i = 0; i != NumEntries; ++i) { - unsigned data = ByteSwap(TempSpace[i], true); - if (data != (unsigned)-1) { // only load data if its not MissingVal - if (Data[i] == (unsigned)-1) { - Data[i] = data; - } else { - Data[i] += data; - } - } + Data[i] = AddCounts(ByteSwap(TempSpace[i], true), Data[i]); } } } |