[PATCH] D32819: [IR] Switch AttributeList to use an array for O(1) access

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 11:40:43 PDT 2017


rnk created this revision.

Before this change, AttributeLists stored a pair of index and
AttributeSet. This is memory efficient if most arguments do not have
attributes. However, it requires doing a search over the pairs to test
an argument or function attribute. Profiling shows that this loop was
0.76% of the time in 'opt -O2' of sqlite3.c, because LLVM constantly
tests values for nullability.

The attribute list indexing change is not strictly necessary. We could
add one to the indices inside AttributeListImpl::getAttributes, but that
felt unclean to me. Now that we've cured the "ArgNo+1" disease that
previously afflicted the codebase, we might as well change the indices
to make more sense.

TODO: I need to re-run my benchmark with these change, but the
workstation I use for profiling is currently offline. I'll add them to
the commit message when I get them. In the meantime, please review.


https://reviews.llvm.org/D32819

Files:
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32819.97697.patch
Type: text/x-patch
Size: 35985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/6bd5c1aa/attachment.bin>


More information about the llvm-commits mailing list