Bug 27549 - [4.1 Regression] ICE in coalesce_abnormal_edges
Summary: [4.1 Regression] ICE in coalesce_abnormal_edges
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P1 normal
Target Milestone: 4.1.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 27550 27551 (view as bug list)
Depends on: 27283
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-11 08:44 UTC by Jakub Jelinek
Modified: 2006-05-17 08:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-12 04:48:25


Attachments
gcc41-pr27549.patch (3.81 KB, patch)
2006-05-15 10:10 UTC, Jakub Jelinek
Details | Diff
gcc41-pr27548.patch (1.46 KB, patch)
2006-05-15 10:11 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2006-05-11 08:44:36 UTC
typedef __SIZE_TYPE__ size_t;

struct E
{
  virtual ~E () {}
  virtual size_t e () const = 0;
  virtual void f (char *x) const = 0;
};

struct F : public E
{
  virtual ~F () {}
  virtual size_t e () const { return 0; }
  virtual void f (char *x) const { *x = '\0'; }
};

struct S
{
  S () { a = new char[32]; b = 32; c = 0; a[0] = 0; }
  void s (const char *x, size_t y) { v (c + y + 1); __builtin_memcpy(a + c, x, y); c += y; a[c] = '\0'; }
  void s (const E *x) { size_t l = x->e(); v (c + l + 1); x->f (a + c); c += l; }
  const char *t () { return a; }
  void v (size_t n)
    {
      if (b >= n) return;

      size_t b2 = b;
      char *a2 = a;

      for (;;)
        {
          b *= 2;
          if (b >= n)
            break;
        }

      a = new char[b];

      if (b2)
        {
          __builtin_memcpy(a, a2, c);
          a2[0] = 0;
          for (size_t i = 1; i < b2; i++)
            a2[i] = a2[i - 1];
          delete[] a2;
        }
    }

  ~S ()
    {
      if (b)
        {
          a[0] = 0;
          for (size_t i = 1; i < b; i++)
            a[i] = a[i - 1];
        }
      delete[] a;
    }
  char * a;
  size_t b, c;
};

const char *p;
size_t q;
const F u;

const char *
foo ()
{
  S s;
  s.s (p, q);
  s.s (&u);
  return s.t ();
}

ICEs at -O{1,2,3} in coalesce_abnormal_edges, at least on x86_64 and i386 linux.
Comment 1 Andrew Pinski 2006-05-11 08:48:14 UTC
This worked in "4.1.0 20060208" and in "4.1.0 20051026".
Comment 2 Andrew Pinski 2006-05-11 08:50:53 UTC
Does the patch for PR 27283 fix this?
Comment 3 Jakub Jelinek 2006-05-11 09:06:40 UTC
*** Bug 27550 has been marked as a duplicate of this bug. ***
Comment 4 Jakub Jelinek 2006-05-11 09:06:56 UTC
*** Bug 27551 has been marked as a duplicate of this bug. ***
Comment 5 Jakub Jelinek 2006-05-11 09:07:40 UTC
Yes, PR 27283 patch fixes this.  So, we need it on gcc-4_1-branch too...
Comment 6 Andrew Pinski 2006-05-12 04:48:25 UTC
Confirmed.
Comment 7 Jakub Jelinek 2006-05-15 10:10:02 UTC
Created attachment 11468 [details]
gcc41-pr27549.patch
Comment 8 Jakub Jelinek 2006-05-15 10:11:16 UTC
Created attachment 11469 [details]
gcc41-pr27548.patch

These two patches fix this on the branch, bootstrapped/regtested on 7 linux
arches.  But, PR27548 fix hasn't been approved for the trunk yet, so I'll post
these 2 to gcc-patches only when that happens.
Comment 9 Jakub Jelinek 2006-05-17 08:24:07 UTC
Subject: Bug 27549

Author: jakub
Date: Wed May 17 08:23:55 2006
New Revision: 113843

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113843
Log:
	PR tree-optimization/27549
	Backported from mainline

	2006-05-01  Zdenek Dvorak  <dvorakz@suse.cz>

	PR tree-optimization/27283
	* tree-ssa-loop-ivopts.c (struct nfe_cache_elt): Store just trees,
	not whole # of iteration descriptions.
	(niter_for_exit): Return just # of iterations.  Fail if # of iterations
	uses abnormal ssa name.
	(niter_for_single_dom_exit): Ditto.
	(find_induction_variables, may_eliminate_iv): Expect niter_for_exit to
	return just the number of iterations.
	(add_iv_outer_candidates, may_replace_final_value): Likewise.

	* g++.dg/tree-ssa/pr27283.C: New test.
	* g++.dg/tree-ssa/pr27549.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/tree-ssa/pr27283.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/tree-ssa/pr27549.C
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-ssa-loop-ivopts.c

Comment 10 Jakub Jelinek 2006-05-17 08:32:01 UTC
Subject: Bug 27549

Author: jakub
Date: Wed May 17 08:31:51 2006
New Revision: 113845

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113845
Log:
	PR tree-optimization/27549
	* g++.dg/tree-ssa/pr27549.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/tree-ssa/pr27549.C
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 11 Jakub Jelinek 2006-05-17 08:46:50 UTC
Fixed in SVN.