InstrProf: Don't keep a large sparse list around just to zero it
authorJustin Bogner <mail@justinbogner.com>
Thu, 2 Oct 2014 16:04:03 +0000 (16:04 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 2 Oct 2014 16:04:03 +0000 (16:04 +0000)
commit1476756523da72f668332f1d69692aa3ab838014
tree99ca1079bdde355613fa69bd79d29fa580aad36b
parentdafb357bb54662cb350491926bdb59604969bc1d
InstrProf: Don't keep a large sparse list around just to zero it

The Terms vector here represented a polynomial of of all possible
counters, and is used to simplify expressions when generating coverage
mapping. There are a few problems with this:

1. Keeping the vector as a member is wasteful, since we clear it every
   time we use it.
2. Most expressions refer to a subset of the counters, so we end up
   iterating over a large number of zeros doing nothing a lot of the
   time.

This updates the user of the vector to store the terms locally, and
uses a sort and combine approach so that we only operate on counters
that are actually used in a given expression. For small cases this
makes very little difference, but in cases with a very large number of
counted regions this is a significant performance fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218879 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ProfileData/CoverageMapping.h
lib/ProfileData/CoverageMapping.cpp