Hi, On 2019-10-01 12:17:08 -0400, Tom Lane wrote: > FYI, I checked into whether this would result in worse generated code. > In the one place I checked (InsertPgAttributeTuple, which hopefully > is representative), I got *exactly the same* assembly code before > and after, on both a somewhat-aging gcc and fairly modern clang. > Hadn't quite expected that, but it removes any worries about whether > we might be losing anything.
I think the only case where it's plausible to be really worse is where we intentionally leave part of such allocations uninitialized - which we can't easily do in these cases because the rest of the struct will also get zeroed out. The compiler will probably figure it out in some cases, but there's plenty where it can't. But I don't think there's many places like that in our code though. > Note though that InsertPgAttributeTuple uses memset(), while some of > these other places use MemSet(). The code I see being generated for > MemSet() is also the same(!) on clang, but it is different and > probably worse on gcc. I wonder if it isn't time to kick MemSet to > the curb. We have not re-evaluated that macro in more than a dozen > years, and compilers have surely changed. Yes, we really should! - Andres