HomePhabricator

[llvm-readobj] Optimize printing stack sizes to linear time.

Authored by rahmanl on May 26 2021, 1:12 PM.

Description

[llvm-readobj] Optimize printing stack sizes to linear time.

Currently, each function name lookup is a linear iteration over all symbols defined in the object file which makes the total running time quadratic.

This patch optimizes the function name lookup by populating an address to index map upon the first function name lookup which is used to lookup each function name in O(1).

impact: For the clang binary built with -fstack-size-section, this improves the running time of llvm-readobj --stack-size from 7 minutes to 0.25 seconds.

Reviewed By: jhenderson

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