]> granicus.if.org Git - clang/commit
InstrProf: Avoid repeated linear searches in a hot path
authorJustin Bogner <mail@justinbogner.com>
Wed, 1 Oct 2014 03:33:52 +0000 (03:33 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 1 Oct 2014 03:33:52 +0000 (03:33 +0000)
commitf5d5d35e7e7744aa4dde1ed9180a3212fd9eb7f7
tree79d9a58967b21d8bed5ef1e8c96e375f360d25d4
parente740642d93d0a40767f89fa73927f35c636b425a
InstrProf: Avoid repeated linear searches in a hot path

When generating coverage regions, we were doing a linear search
through the existing regions in order to try to merge related ones.
Most of the time this would find what it was looking for in a small
number of steps and it wasn't a big deal, but in cases with many
regions and few mergeable ones this leads to an absurd compile time
regression.

This changes the coverage mapping logic to do a single sort and then
merge as we go, which is a bit simpler and about 100 times faster.
I've also added FIXMEs on a couple of behaviours that seem a little
suspect, while keeping them behaving as they were - I'll look into
these soon.

The test changes here are mostly tedious reorganization, because the
ordering of regions we output has become slightly (but not completely)
more consistent from the almost completely arbitrary ordering we got
before.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218738 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/includehell.cpp
test/CoverageMapping/loopmacro.c
test/CoverageMapping/macroception.c
test/CoverageMapping/macroparams.c