[all-commits] [llvm/llvm-project] d54c25: [Clang options] Optimize optionMatches() runtime b...

Nadav Rotem via All-commits all-commits at lists.llvm.org
Wed Aug 12 23:10:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d54c252bc8a15bc80bb9f0a83b3bebc6d211144a
      https://github.com/llvm/llvm-project/commit/d54c252bc8a15bc80bb9f0a83b3bebc6d211144a
  Author: Nadav Rotem <nadav256 at gmail.com>
  Date:   2020-08-12 (Wed, 12 Aug 2020)

  Changed paths:
    M llvm/lib/Option/OptTable.cpp

  Log Message:
  -----------
  [Clang options] Optimize optionMatches() runtime by removing mallocs

The method optionMatches() constructs 9865 std::string instances when comparing different
options. Many of these instances exceed the size of the internal storage and force memory
allocations. This patch adds an early exit check that eliminates most of the string allocations
while keeping the code simple.

Example inputs:
Prefix: /, Name: Fr
Prefix: -, Name: Fr
Prefix: -, Name: fsanitize-address-field-padding=
Prefix: -, Name: fsanitize-address-globals-dead-stripping
Prefix: -, Name: fsanitize-address-poison-custom-array-cookie
Prefix: -, Name: fsanitize-address-use-after-scope
Prefix: -, Name: fsanitize-address-use-odr-indicator
Prefix: -, Name: fsanitize-blacklist=

Differential Revision: D85538




More information about the All-commits mailing list