[all-commits] [llvm/llvm-project] 2c84b9: Fix assertion in SmallDenseMap constructor with re...
David Blaikie via All-commits
all-commits at lists.llvm.org
Mon Jul 25 10:09:59 PDT 2022
Author: Vladislav Dzhidzhoev <vdzhidzhoev at accesssoftek.com>
Date: 2022-07-25 (Mon, 25 Jul 2022)
Fix assertion in SmallDenseMap constructor with reserve from non-power-of-2 buckets count
`SmallDenseMap` constructor with reserve gets an arbitrary `NumInitBuckets` value and passes it below to `init` method.
If `NumInitBuckets` is greater then `InlineBuckets`, then `SmallDenseMap` initializes to large representation passing `NumInitBuckets` below to `DenseMap` initialization. `DenseMap::initEmpty` method asserts that initial buckets count must be a power of 2.
Proposed solution is to update `NumInitBuckets` value in `SmallDenseMap` constructor till the next power of 2. It should satisfy both `DenseMap` preconditions and required minimum buckets count for reservation.
Reviewed By: atrick
Differential Revision: https://reviews.llvm.org/D129825
More information about the All-commits