On Fri, Sep 05, 2025 at 05:19:06PM +0200, Jason Merrill wrote: > > Regarding temporaries, I wonder if we want to .DEFERRED_INIT them when > > expanding TARGET_EXPRs in the gimplifier (but whether to do that always > > when flag_auto_var_init != AUTO_INIT_UNINITIALIZED or for C++26 only), > > or if it should be in the C++ gimplification hook (but then it is more > > costly because it would need to create a GENERIC IFN CALL only to > > immediately gimplify it). > > I guess doing it whenever flag_auto_var_init is set makes sense.
If Qing is ok with that, sure. > > PARM_DECLs from function declarations (rather than definitions) are thrown > > away, so guess we need to remember those say in some custom attribute on > > the FUNCTION_DECLs (indexes of parameters with the attribute) and perhaps > > when the FE creates TARGET_EXPRs for those params, mark their > > TARGET_EXPR_SLOT with indeterminate attribute. > > Doesn't the "Merge parameter attributes" code in duplicate_decls address > this? I'll have a look next week. > > And really no idea what should be done about the skipped vacuous > > initializations, I've mentioned some ideas in > > https://github.com/cplusplus/CWG/issues/758#issuecomment-3253963911 > > but it all seems quite costly to me. For non-addressable gimple reg > > type ones perhaps just mark those vars specially so that at SSA construction > > time we don't use (D) SSA_NAMEs for the uninitialized paths but instead > > create .DEFERRED_INIT call somewhere dominating all the "uninitialized" > > uses and use that SSA_NAME instead (though, not sure about > > SSA_NAME_OCCURS_IN_ABNORMAL_PHIs). But for other vars (addressable or > > non-scalar)? > > I guess we could change > > { > T t; > do_stuff (); > label: > do_more (); > } > > to > > { > T t = ERR; > do_stuff (); > goto skip; > label: > t = ERR; > skip: > do_more (); > } Yeah, that is roughly what I've mentioned in the github CWG issue too, use if (0) { labalt1: x1 = ERR; labalt2: x2 = ERR; labalt3: x3 = ERR; } lab: there with grouping gotos depending on the set of vacuous initializations they skip over. Of course, jumps to case labels from switch always skip the same set of vars and in that case the case/default needs to move. And it will need to somehow interact with [[fallthrough]]. Will play with that next week. Jakub