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

            Bug ID: 95569
           Summary: ICE in tmmark:verify_ssa failed
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qianchao9 at huawei dot com
  Target Milestone: ---

Created attachment 48698
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48698&action=edit
mark tree-addressable

Commit eb72dc663e9070b281be83a80f6f838a3a878822 introduces a ICE on AArch64.

Compiling this with -S -fgnu-tm -O0:

typedef int __attribute__ ((vector_size (16))) vectype;
vectype v;

void
foo (int c)
{
  vectype *p = __builtin_malloc (sizeof (vectype));
  __transaction_atomic
  {
    *p = v;
    if (c)
      __transaction_cancel;
  }
}

gives:

testcase.c: In function ‘foo’:
testcase.c:5:1: error: virtual definition of statement not up to date
    5 | foo (int c)
      | ^~~
D.3669 = v.0_11;
during GIMPLE pass: tmmark
testcase.c:5:1: internal compiler error: verify_ssa failed

on the tmmark output is:    

....
<L0>:
  __builtin__ITM_memcpyRtWn (&D.3667, &v, 16);
  v.0_11 = D.3667;
  D.3668 = v.0_11;
  __builtin__ITM_memcpyRnWt (p_4, &D.3668, 16);

...

the following fixes the latent bug - we failed to mark 'D.3668'
TREE_ADDRESSABLE (address-taken)

diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index c23ecd2b31f..b6b9157006b 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -2424,6 +2424,7 @@ expand_assign_tm (struct tm_region *region,
gimple_stmt_iterator *gsi)
       if (is_gimple_reg (rhs))
        {
          tree rtmp = create_tmp_var (TREE_TYPE (rhs));
+         TREE_ADDRESSABLE (rtmp) = 1;
          rhs_addr = build_fold_addr_expr (rtmp);
          gcall = gimple_build_assign (rtmp, rhs);
          gsi_insert_before (gsi, gcall, GSI_SAME_STMT);

Reply via email to