On February 26, 2016 5:15:43 PM GMT+01:00, Martin Jambor <mjam...@suse.cz> 
wrote:
>Hi,
>
>my fix for PR 69666 has caused quite a few regressions accross the
>borad where SRA removed a SSA_NAME which however still was in the IL
>(and usually stumbled upon it itself straight away).
>
>The removal path should not be executed when there is an SSA_NAME on
>the LHS, the code clearly is not ready for it.  Before my patch, we
>got always lucky because the statement was simply modified elsewhere
>when the LHS was an SSA_NAME.  However, even that was not 10%
>guaranteed because of the !access_has_replacements_p (racc) part of
>the changed condition.
>
>The patch below fixes the ICEs simply by guarding the removal code to
>only work when the LHS is not an SSA_NAME.  This means that the safe
>path below it is going to execute.
>
>I have bootstrapped and tested the patch on x86_64-linux.  I'd like to
>commit it to trunk as soon as it gets approved and then I'd like to
>commit it to gcc-5 branch together with the PR 69666 fix a few days
>afterwards.  OK?

OK.

Richard.

>Thanks,
>
>Martin
>
>
>2016-02-26  Martin Jambor  <mjam...@suse.cz>
>
>       PR middle-end/69920
>       * tree-sra.c (sra_modify_assign): Do not remove loads of
>       uninitialized aggregates to SSA_NAMEs.
>
>testsuite/
>       * gcc.dg/torture/pr69932.c: New test.
>       * gcc.dg/torture/pr69936.c: Likewise.
>---
> gcc/testsuite/gcc.dg/torture/pr69932.c | 10 ++++++++++
> gcc/testsuite/gcc.dg/torture/pr69936.c | 24 ++++++++++++++++++++++++
> gcc/tree-sra.c                         |  3 ++-
> 3 files changed, 36 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/torture/pr69932.c
> create mode 100644 gcc/testsuite/gcc.dg/torture/pr69936.c
>
>diff --git a/gcc/testsuite/gcc.dg/torture/pr69932.c
>b/gcc/testsuite/gcc.dg/torture/pr69932.c
>new file mode 100644
>index 0000000..4b82130
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/torture/pr69932.c
>@@ -0,0 +1,10 @@
>+/* { dg-do compile } */
>+
>+int a;
>+void fn1() {
>+  int b = 4;
>+  short c[4];
>+  c[b] = c[a];
>+  if (c[2]) {}
>+
>+}
>diff --git a/gcc/testsuite/gcc.dg/torture/pr69936.c
>b/gcc/testsuite/gcc.dg/torture/pr69936.c
>new file mode 100644
>index 0000000..3023bbb
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/torture/pr69936.c
>@@ -0,0 +1,24 @@
>+/* { dg-do compile } */
>+
>+int a;
>+char b;
>+void fn1(int p1) {}
>+
>+int fn2() { return 5; }
>+
>+void fn3() {
>+  if (fn2())
>+    ;
>+  else {
>+    char c[5];
>+    c[0] = 5;
>+  lbl_608:
>+    fn1(c[9]);
>+    int d = c[9];
>+    c[2] | a;
>+    d = c[b];
>+  }
>+  goto lbl_608;
>+}
>+
>+int main() { return 0; }
>diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
>index 663ded2..366f413 100644
>--- a/gcc/tree-sra.c
>+++ b/gcc/tree-sra.c
>@@ -3504,7 +3504,8 @@ sra_modify_assign (gimple *stmt,
>gimple_stmt_iterator *gsi)
>       else
>       {
>         if (access_has_children_p (racc)
>-            && !racc->grp_unscalarized_data)
>+            && !racc->grp_unscalarized_data
>+            && TREE_CODE (lhs) != SSA_NAME)
>           {
>             if (dump_file)
>               {


Reply via email to