[llvm] r214228 - Coverage: improve efficiency of the counter propagation to the expansion regions.

Alex Lorenz arphaman at gmail.com
Tue Jul 29 14:42:25 PDT 2014


Author: arphaman
Date: Tue Jul 29 16:42:24 2014
New Revision: 214228

URL: http://llvm.org/viewvc/llvm-project?rev=214228&view=rev
Log:
Coverage: improve efficiency of the counter propagation to the expansion regions.

This patch reduces the complexity of the two inner loops in order to speed up 
the loading of coverage data for very large functions.

Modified:
    llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp

Modified: llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp?rev=214228&r1=214227&r2=214228&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp Tue Jul 29 16:42:24 2014
@@ -251,15 +251,19 @@ std::error_code RawCoverageMappingReader
   // from the expanded file.
   // Perform multiple passes to correctly propagate the counters through
   // all the nested expansion regions.
+  SmallVector<CounterMappingRegion *, 8> FileIDExpansionRegionMapping;
+  FileIDExpansionRegionMapping.resize(VirtualFileMapping.size(), nullptr);
   for (unsigned Pass = 1, S = VirtualFileMapping.size(); Pass < S; ++Pass) {
-    for (auto &I : MappingRegions) {
-      if (I.Kind == CounterMappingRegion::ExpansionRegion) {
-        for (const auto &J : MappingRegions) {
-          if (J.FileID == I.ExpandedFileID) {
-            I.Count = J.Count;
-            break;
-          }
-        }
+    for (auto &R : MappingRegions) {
+      if (R.Kind != CounterMappingRegion::ExpansionRegion)
+        continue;
+      assert(!FileIDExpansionRegionMapping[R.ExpandedFileID]);
+      FileIDExpansionRegionMapping[R.ExpandedFileID] = &R;
+    }
+    for (auto &R : MappingRegions) {
+      if (FileIDExpansionRegionMapping[R.FileID]) {
+        FileIDExpansionRegionMapping[R.FileID]->Count = R.Count;
+        FileIDExpansionRegionMapping[R.FileID] = nullptr;
       }
     }
   }





More information about the llvm-commits mailing list