bcraig added a comment. In http://reviews.llvm.org/D15539#312336, @jroelofs wrote:
> In http://reviews.llvm.org/D15539#312332, @bcraig wrote: > > > In http://reviews.llvm.org/D15539#312319, @jroelofs wrote: > > > > > What does having them be `long double`s give over just multiplying the > > > counts by 16 (or however big it is on your platform)? Alignment? > > > > > > Seems like it'd be better to start with a prime that's ~16x larger, say > > > 211, than to have that factor of 16 floating around everywhere. > > > > > > Alignment is the main answer. I'd use max_align_t directly, except that it > > got added in C++11, and this test should be able to run in C++98 and C++03. > > Using a large type instead of a char also makes it easier to avoid making > > two padding values that look different, but aren't actually all that > > different due to internal padding. Just starting at a high prime wouldn't > > fix this, as then I have to ensure that consecutive values are separated by > > at least sizeof(void *). > > > What platform are you on where sizeof(void*) is anywhere near 13 bytes? I'm on a platform where void* is 4 bytes (Hexagon). That's not what I was getting at though. Lets take x86_64 as an example instead. #include <iostream> struct A { virtual ~A() {} char _[17]; }; struct B { virtual ~B() {} char _[19]; }; struct C { virtual ~C() {} char _[23]; }; int main() { std::cout<<"A: "<<sizeof(A)<<std::endl; //prints 32 std::cout<<"B: "<<sizeof(B)<<std::endl; //prints 32 std::cout<<"C: "<<sizeof(C)<<std::endl; //prints 32 return 0; } I could reasonable see an optimizer collapsing some of these classes together in some way or another. If you change the chars out for long doubles, then all three classes have different sizes. http://reviews.llvm.org/D15539 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits