https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123475

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
r16-4212 does the right thing, there is a TARGET_EXPR with void type
initializer, which is what is used if the whole TARGET_EXPR_SLOT isn't
initialized to the initializer expression.  In such cases it needs to be marked
.DEFERRED_INIT before being initialized, as the initializer might not
initialize everything or already the initializer might dereference the slot.
The problem is that the C FE marks the TARGET_EXPR_SLOT as TREE_ADDRESSABLE
because it initializes it as __atomic_load_n (&expr, &tmp, SEQ_CST); but
because it is a supported size for hw supported __atomic_load_{1,2,4,8,16}, it
is folded immediately into tmp = __atomic_load_4 (&expr, SEQ_CST).  Nothing
adjusted the TARGET_EXPR to have non-void __atomic_load_4 (&expr, SEQ_CST)
initializer, so gimplifier with -ftrivial-auto-var-init=zero needs to
preinitialize, because the slot is addressable and has gimple reg type
.DEFERRED_INIT is forced into a temporary SSA_NAME instead of being written
directly into it, but as nothing in the IL actually takes address of the slot,
when converted into SSA form we end up with
  c_6 = .DEFERRED_INIT (4, 2, &"c"[0]);
  _1 = .DEFERRED_INIT (4, 2, &"D.2963"[0]);
  _7 = _1;
during early_uninit pass and warn on the dead but not yet discovered as dead _7
= _1;
SSA_NAME copy.  For c itself we don't warn (other than
-Wunused-but-set-variable) because it wasn't addressable and so gimplification
produced
      c = .DEFERRED_INIT (4, 2, &"c"[0]);
rather than
      _1 = .DEFERRED_INIT (4, 2, &"D.2963"[0]);
      D.2963 = _1;
and if c is address taken somewhere else and the address taking is not
optimized away by early_uninit time, it would be
      _2 = .DEFERRED_INIT (4, 2, &"c"[0]);
      c = _2;
but no warning for that case as the lhs is at that point still TREE_ADDRESSABLE
VAR_DECL and I think we don't warn about .DEFERRED_INIT stores into memory (at
least not at that point).

Reply via email to