Iterating on SmallPtrSet<GlobalValue *, 8> with more than 8 elements
is not deterministic. Use a SmallVector instead because Used is guaranteed to contain unique elements.
While here, decrease inline element counts from 8 to 4. The number of
llvm.used/llvm.compiler.used elements is usually 0 or 1. For full
LTO/hybrid LTO, the number may be large, so we need to be careful.
According to tejohnson's analysis https://reviews.llvm.org/D97128#2582399 , 4 is
good for a large project with WholeProgramDevirt, when available_externally
vtables are placed in the llvm.compiler.used set.
Can you add a comment for the new interface? The one above is stale as it talks about using a Set. It would also be good to add the rationale for using a vector, so no one decides to do a "cleanup" and switch back to a set later on.