[PATCH] D117558: [AttrBuilder] Change storage to sorted vector

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 18 10:59:28 PST 2022


aeubanks accepted this revision.
aeubanks added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/lib/IR/Attributes.cpp:1529
 
-struct StringAttributeComparator {
+struct AttributeComparator {
   bool operator()(Attribute A0, Attribute A1) const {
----------------
perhaps a note about string attrs being considered greater than enum attrs would be nice


================
Comment at: llvm/lib/IR/Attributes.cpp:1706
 AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) {
-  for (unsigned Index = 0; Index < Attribute::NumIntAttrKinds; ++Index)
-    if (B.IntAttrs[Index])
-      IntAttrs[Index] = B.IntAttrs[Index];
-
-  for (unsigned Index = 0; Index < Attribute::NumTypeAttrKinds; ++Index)
-    if (B.TypeAttrs[Index])
-      TypeAttrs[Index] = B.TypeAttrs[Index];
-
-  Attrs |= B.Attrs;
-
   // TODO: could merge both lists in one loop
+  for (const auto &I : B.attrs())
----------------
no longer relevant


================
Comment at: llvm/lib/IR/Attributes.cpp:1708
+  for (const auto &I : B.attrs())
     addAttribute(I);
 
----------------
could make this O(n) since they're both sorted, maybe a FIXME


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117558/new/

https://reviews.llvm.org/D117558



More information about the llvm-commits mailing list