[PATCH] D31232: [IR] Use a binary search in DataLayout::getAlignmentInfo

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 20:46:20 PDT 2017


mehdi_amini added a comment.

It is not clear to me why an associative container instead of a vector wouldn't be even easier to use?



================
Comment at: include/llvm/IR/DataLayout.h:123
+  typedef SmallVector<LayoutAlignElem, 16> AlignmentsTy;
+  AlignmentsTy Alignments;
+
----------------
Document that it is sorted by construction.


================
Comment at: lib/IR/DataLayout.cpp:443
+    Alignments.insert(I, LayoutAlignElem::get(align_type, abi_align,
+                                              pref_align, bit_width));
   }
----------------
Here as well: a reference to the fact that we insert in the right position to keep the vector sorted.


https://reviews.llvm.org/D31232





More information about the llvm-commits mailing list