https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105260
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jamborm at gcc dot gnu.org Keywords|ABI, wrong-code | --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't see any ABI differences, nor wrong-code. If you look at *.optimized dump differences, there are pretty much none, except for one extra CLOBBER. But there are 2 differences not visible in the dump. One is that while neither un variable is TREE_ADDRESSABLE, the no WORKAROUND one has TREE_ADDRESSABLE type (as it has non-trivial destructor). The other difference that matters for this testcase is that TYPE_MODE of the NoDestroy union type is BLKmode, while for WORKAROUND=1 case it is DImode. This is both done in: /* If this type has a copy constructor or a destructor, force its mode to be BLKmode, and force its TREE_ADDRESSABLE bit to be nonzero. This will cause it to be passed by invisible reference and prevent it from being returned in a register. */ if (type_has_nontrivial_copy_init (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) { tree variants; SET_DECL_MODE (TYPE_MAIN_DECL (t), BLKmode); for (variants = t; variants; variants = TYPE_NEXT_VARIANT (variants)) { SET_TYPE_MODE (variants, BLKmode); TREE_ADDRESSABLE (variants) = 1; } } Now, for the ABI passing the above is really required, such types are indeed passed differently from ones that have trivialy copy ctor and dtor, but for this testcase it is just an optimization decision (use_register_for_decl). We do there: /* Only register-like things go in registers. */ if (DECL_MODE (decl) == BLKmode) return false; Guess we'd need to recompute mode for non-TREE_ADDRESSABLE vars before expansion. Or find out why SRA doesn't optimize this (remove the useless union, replace all the un.value occurrences with a var with Foo type.