On Tue, Oct 06, 2026 at 04:18:31PM +0800, Xiaoyi Suo wrote: > Tom, > > > Why is this last memset call clear here safe? I'm not saying it's not, I > > just want to be clear. > > sctx is the caller's object, not ours - it comes in as a pointer argument, so > the write is a visible side effect and the compiler has no way to show it is > dead. W is a local array that nothing reads after the clear, which is why > those two do get dropped. > > I went and looked at the dse dump to be sure (GCC 13.3, > -fdump-tree-dse-details). At -O1, -O2 and -Os it reports only the two: > > sm3_update: Deleted dead call: memset (&W, 0, 64); > sm3_final: Deleted dead call: memset (&W, 0, 64); > > and nothing on sctx. With W as memzero_explicit() the same dump has no deleted > memset left at all. > > One thing I ran into while checking: there is also a "Trimming statement" line > in that dump, but it is sm3_init(), not sm3_final(). That memset() is an > initialisation anyway - the pass drops its first 32 bytes because the IV is > written over state[] right after. > > If you would rather see the helper on the sctx clear too, happy to send it > that > way. I left it alone because nothing removes it today.
Thanks for explaining. Reviewed-by: Tom Rini <[email protected]> -- Tom
signature.asc
Description: PGP signature
