[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext
Steven Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 13 15:38:49 PST 2023
steven_wu added a comment.
In D141625#4052869 <https://reviews.llvm.org/D141625#4052869>, @rsmith wrote:
> In D141625#4052820 <https://reviews.llvm.org/D141625#4052820>, @dblaikie wrote:
>
>> Yeah, might be nice to document where the instability comes from - if it comes from a DenseMap or similar, then a test that fails either in forward or reverse iteration mode would be nice to have.
>
> `Scope::decls` is iterating over a `SmallPtrSet`. This might be a little annoying to create a test for, because it'll only be unstable if we have two decls in the same prototype scope that get allocated into different slabs by the bump ptr allocator, but maybe something like:
>
> void f(struct A *p, int arr[1 + 0 + 0 + 0 + ... + 0], struct B *q);
>
> ... would be enough (with sufficient subexpressions to fill a whole slab). Then we can build a .pch for that twice and check that it comes out identical.
Yeah, it is really hard to trigger a failure. Even the second decl gets onto a different slab, the second slab will most likely come after the previous one when there isn't much memory pressure.
I can write a test like that but it is really hard to trigger without an enormous module (building Darwin module from macOS SDK can reproduce very reliable).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141625/new/
https://reviews.llvm.org/D141625
More information about the cfe-commits
mailing list