OSDN Git Service

[IR] Store attributes that are available "somewhere" (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Jun 2020 20:49:57 +0000 (22:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 27 Jun 2020 08:44:59 +0000 (10:44 +0200)
commit9a334a4d204127a6941071694bd7c67d6ab31acb
treea0ec9a0066e860fac702349494655a2f564035f2
parentba2ac689e606f1011d9a5b260c31a399316514df
[IR] Store attributes that are available "somewhere" (NFC)

I noticed that for some benchmarks we spend quite a bit of time
inside AttributeList::hasAttrSomewhere(), mainly when checking
for the "returned" attribute. Most of the time the attribute will
not be present, in which case this function has to walk through
the whole attribute list and check for the attribute at each index.

This patch adds a cache of all "available somewhere" attributes
inside AttributeListImpl. This makes the structure 12 bytes larger,
but I don't think that's problematic, as attribute lists are uniqued.
Compile-time in terms of instructions retired improves by 0.4% on
average, but >1% for sqlite.

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