[llvm-commits] [llvm] r80909 - /llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp
Andreas Neustifter
astifter-llvm at gmx.at
Thu Sep 3 01:41:06 PDT 2009
Author: astifter
Date: Thu Sep 3 03:41:05 2009
New Revision: 80909
URL: http://llvm.org/viewvc/llvm-project?rev=80909&view=rev
Log:
Code Cleanup.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090831/086139.html)
Modified:
llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp
Modified: llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp?rev=80909&r1=80908&r2=80909&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileInfoLoader.cpp Thu Sep 3 03:41:05 2009
@@ -32,6 +32,13 @@
((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 @@
// 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]);
}
}
}
More information about the llvm-commits
mailing list