[IR] Optimize adding attribute to AttributeList (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 22 Jan 2021 09:38:36 +0000 (10:38 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 22 Jan 2021 10:30:21 +0000 (11:30 +0100)
commit176c7f22172eefddc9ff42dfae8a6015d4e017c6
tree451676d9cdc8907364cb006ab3ea2b3c9800fe28
parent509741382f6db7687f33bb2fd35cc6a58b058001
[IR] Optimize adding attribute to AttributeList (NFC)

When adding an enum attribute to an AttributeList, avoid going
through an AttrBuilder and instead directly add the attribute to
the correct set. Going through AttrBuilder is expensive, because
it requires all string attributes to be reconstructed.

This can be further improved by inserting the attribute at the
right position and using the AttributeSetNode::getSorted() API.

This recovers the small compile-time regression from D94633.
llvm/include/llvm/IR/Attributes.h
llvm/lib/IR/Attributes.cpp