]> granicus.if.org Git - llvm/commitdiff
[Statistics] Use Statistic::operator+= instead of adding and assigning separately.
authorCraig Topper <craig.topper@gmail.com>
Wed, 17 May 2017 23:22:10 +0000 (23:22 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 17 May 2017 23:22:10 +0000 (23:22 +0000)
I believe this technically fixes a multithreaded race condition in this code. But my primary concern was as part of looking at removing the ability to treat Statistics like a plain unsigned. There are many weird operations on Statistics in the codebase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303314 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/EarlyCSE.cpp
lib/Transforms/Scalar/LoadCombine.cpp

index d8f8a58a5fdfae1e4f505814cd7ecad94e94e464..c4f450949e6de421a7b7b781559bae4de2f2219b 100644 (file)
@@ -606,7 +606,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
         if (unsigned Count = replaceDominatedUsesWith(
                 CondInst, TorF, DT, BasicBlockEdge(Pred, BB))) {
           Changed = true;
-          NumCSECVP = NumCSECVP + Count;
+          NumCSECVP += Count;
         }
       }
     }
index 02215d3450c23f80d032cd0dbec30d41ed99c80b..494cbc61bc9c92e7c9ceabaaa7f48d77b2bc04bd 100644 (file)
@@ -228,7 +228,7 @@ bool LoadCombine::combineLoads(SmallVectorImpl<LoadPOPPair> &Loads) {
     L.Load->replaceAllUsesWith(V);
   }
 
-  NumLoadsCombined = NumLoadsCombined + Loads.size();
+  NumLoadsCombined += Loads.size();
   return true;
 }