OSDN Git Service

ArgList: cache index ranges containing arguments with each ID
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Apr 2017 23:19:51 +0000 (23:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Apr 2017 23:19:51 +0000 (23:19 +0000)
commite05ab25f5dd307c15349f5594a47a187817d2332
tree1dea0628e3a8a3a9571bf38763e3451b84959330
parent67dcd802e3251129210b14097e1b4d7f9629e7d5
ArgList: cache index ranges containing arguments with each ID

Improve performance of argument list parsing with large numbers of IDs and
large numbers of arguments, by tracking a conservative range of indexes within
the argument list that might contain an argument with each ID. In the worst
case (when the first and last argument with a given ID are at the opposite ends
of the argument list), this still results in a linear-time walk of the list,
but it helps substantially in the common case where each ID occurs only once,
or a few times close together in the list.

This gives a ~10x speedup to clang's `test/Driver/response-file.c`, which
constructs a very large set of command line arguments and feeds them to the
clang driver.

Differential Revision: https://reviews.llvm.org/D30130

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