[llvm] d980633 - Use SmallVector instead of std::vector to manage storage of llvm::BitVector

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 22:32:57 PDT 2021


Author: serge-sans-paille
Date: 2021-04-21T07:31:28+02:00
New Revision: d9806334d1a42a0338d4db703249d13108f1ef4d

URL: https://github.com/llvm/llvm-project/commit/d9806334d1a42a0338d4db703249d13108f1ef4d
DIFF: https://github.com/llvm/llvm-project/commit/d9806334d1a42a0338d4db703249d13108f1ef4d.diff

LOG: Use SmallVector instead of std::vector to manage storage of llvm::BitVector

This is a follow-up to https://reviews.llvm.org/D100387.

std::vector is not the best storage container here. My local benchmark (counting
the number of instruction when compiling the sqlite3 amalgamation) yields the
following:

- std::vector<BitVector> -> 5,860,885,896
- SmallVector<BitWord, 0> -> 5,858,991,997
- SmallVector<BitWord> -> 5,817,679,224

Differential Revision: https://reviews.llvm.org/D100744

Added: 
    

Modified: 
    llvm/include/llvm/ADT/BitVector.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 21f4860a82ef3..31d3880736338 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -79,7 +79,7 @@ class BitVector {
   static_assert(BITWORD_SIZE == 64 || BITWORD_SIZE == 32,
                 "Unsupported word size");
 
-  using Storage = std::vector<BitWord>;
+  using Storage = SmallVector<BitWord>;
 
   Storage Bits;  // Actual bits.
   unsigned Size; // Size of bitvector in bits.


        


More information about the llvm-commits mailing list