[IR] Use map for string attributes (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 25 Apr 2020 10:21:21 +0000 (12:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 26 Apr 2020 07:38:05 +0000 (09:38 +0200)
commit8f4c78dcf8a454a2a8a0fa04fe34e2162efd4a5c
tree8ac9cbb3630a2f07b61d5a422d5bebb31d2ba85b
parentb9de62c2b69e3b6342045ae82e1532d4f70c6d34
[IR] Use map for string attributes (NFC)

Attributes are currently stored as a simple list. Enum attributes
additionally use a bitset to allow quickly determining whether an
attribute is set. String attributes on the other hand require a
full scan of the list. As functions tend to have a lot of string
attributes (at least when clang is used), this is a noticeable
performance issue.

This patch adds an additional name => attribute map to the
AttributeSetNode, which allows querying string attributes quickly.
This results in a 3% reduction in instructions retired on CTMark.
Changes to memory usage seem to be in the noise (attribute sets are
uniqued, and we don't tend to have more than a few dozen or hundred
unique attribute sets, so adding an extra map does not have a
noticeable cost.)

Differential Revision: https://reviews.llvm.org/D78859
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp