If the match compiler uses the 'verify' mode and we
compile with -O2, some tests comparing the on-the-fly-parser
to the compiled match fail.
Small functions are inlined by the -O2 compile flag.
If we disable function inlining and still compile with -O2,
everything is back to normal.
gdb didn't show anything useful during the mismatch
since the needed variables are optimized out. Once
we start printing them, the problem vanishes, too.
-> Can only be diagnosed at the x86 assembly level.
The problem vanished by switching the invocation order
of Token::Match() and the compiled match, so just swap them.
Also add commented out helper code
to better diagnose mismatch problems.
Verify mode runs the same ::Match pattern on a token
using the on-the-fly parser and the compiled match parser.
The result is compared and we abort on mismatch.
Already detected an error in our test suite, needs investigation.
Profiler runs with gperftools showed we were spending
a lot of time in strlen() even with compiled match patterns.
If you compare a std::string with a plain C-string,
the comparison operator needs to calculate the length
of the C-string via strlen().
We can avoid this by turning all C-strings into C++ strings,
which cache the string length internally.
The match compiler has been adapted to collect all
C-strings during compilation and aggregate them.
Benchmark on the 'rpm' code base on a Core i7 920 box:
cppcheck without matchcompiler:
real 0m30.977s
cppcheck with previous matchcompiler:
real 0m28.157s
cppcheck with cached C-strings:
real 0m17.823s