[PATCH] Coverage: improve efficiency of the counter propagation to the expansion regions.

Justin Bogner mail at justinbogner.com
Tue Jul 29 14:28:06 PDT 2014


Alex Lorenz <arphaman at gmail.com> writes:
> Rename the variable and move the resize out of the loop.

LGTM.

> http://reviews.llvm.org/D4708
>
> Files:
>   lib/ProfileData/CoverageMappingReader.cpp
>
> Index: lib/ProfileData/CoverageMappingReader.cpp
> ===================================================================
> --- lib/ProfileData/CoverageMappingReader.cpp
> +++ lib/ProfileData/CoverageMappingReader.cpp
> @@ -251,15 +251,19 @@
>    // 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