public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/43997]  New: -finline-small-functions related oops
@ 2010-05-05 22:02 dps at simpson dot demon dot co dot uk
  2010-05-05 22:05 ` [Bug middle-end/43997] " dps at simpson dot demon dot co dot uk
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dps at simpson dot demon dot co dot uk @ 2010-05-05 22:02 UTC (permalink / raw)
  To: gcc-bugs

The following source file, which a reduced version of a gmp 5.0.1 test triggers
and internal compiler error when compiled with -finline-small-functions. I have
removed most of what is not required to tickle the bug.

I aware of at least one other file which triggers the same bug for me.

Screen shot:
$ gcc --version
gcc (GCC) 4.6.0 20100504 (experimental)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -c -O -o /tmp/foo.o gcc-bug-red.c 
$ gcc -c -O -finline-small-functions -o /tmp/foo.o gcc-bug-red.c 
gcc-bug-red.c:243:1: internal compiler error: in
cgraph_decide_inlining_of_small_functions, at ipa-inline.c:1007
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ cat gcc-bug-red.c
extern int printf (__const char *__restrict __format, ...);
extern void abort (void) __attribute__ ((__nothrow__)) __attribute__
((__noreturn__));
typedef unsigned long int mp_limb_t;
typedef mp_limb_t * mp_ptr;
typedef const mp_limb_t * mp_srcptr;
typedef long int mp_size_t;
 mp_limb_t __gmpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) ;
 mp_limb_t __gmpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) ;

extern __inline__ __attribute__ ((__gnu_inline__))
mp_limb_t
__gmpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size,
mp_limb_t __gmp_n)
{
  mp_limb_t __gmp_c;
  do { mp_size_t __gmp_i; mp_limb_t __gmp_x, __gmp_r; __gmp_x = (__gmp_src)[0];
__gmp_r = __gmp_x + (__gmp_n); (__gmp_dst)[0] = __gmp_r; if (((__gmp_r) <
((__gmp_n)))) { (__gmp_c) = 1; for (__gmp_i = 1; __gmp_i < (__gmp_size);) {
__gmp_x = (__gmp_src)[__gmp_i]; __gmp_r = __gmp_x + 1; (__gmp_dst)[__gmp_i] =
__gmp_r; ++__gmp_i; if (!((__gmp_r) < (1))) { if ((__gmp_src) != (__gmp_dst))
do { mp_size_t __gmp_j; ; for (__gmp_j = (__gmp_i); __gmp_j < (__gmp_size);
__gmp_j++) (__gmp_dst)[__gmp_j] = (__gmp_src)[__gmp_j]; } while (0); (__gmp_c)
= 0; break; } } } else { if ((__gmp_src) != (__gmp_dst)) do { mp_size_t
__gmp_j; ; for (__gmp_j = (1); __gmp_j < (__gmp_size); __gmp_j++)
(__gmp_dst)[__gmp_j] = (__gmp_src)[__gmp_j]; } while (0); (__gmp_c) = 0; } }
while (0);
  return __gmp_c;
}
extern __inline__ __attribute__ ((__gnu_inline__))
mp_limb_t
__gmpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size,
mp_limb_t __gmp_n)
{
  mp_limb_t __gmp_c;
  do { mp_size_t __gmp_i; mp_limb_t __gmp_x, __gmp_r; __gmp_x = (__gmp_src)[0];
__gmp_r = __gmp_x - (__gmp_n); (__gmp_dst)[0] = __gmp_r; if (((__gmp_x) <
((__gmp_n)))) { (__gmp_c) = 1; for (__gmp_i = 1; __gmp_i < (__gmp_size);) {
__gmp_x = (__gmp_src)[__gmp_i]; __gmp_r = __gmp_x - 1; (__gmp_dst)[__gmp_i] =
__gmp_r; ++__gmp_i; if (!((__gmp_x) < (1))) { if ((__gmp_src) != (__gmp_dst))
do { mp_size_t __gmp_j; ; for (__gmp_j = (__gmp_i); __gmp_j < (__gmp_size);
__gmp_j++) (__gmp_dst)[__gmp_j] = (__gmp_src)[__gmp_j]; } while (0); (__gmp_c)
= 0; break; } } } else { if ((__gmp_src) != (__gmp_dst)) do { mp_size_t
__gmp_j; ; for (__gmp_j = (1); __gmp_j < (__gmp_size); __gmp_j++)
(__gmp_dst)[__gmp_j] = (__gmp_src)[__gmp_j]; } while (0); (__gmp_c) = 0; } }
while (0);
  return __gmp_c;
}

typedef mp_limb_t (*mpn_aors_1_t)
     (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
mpn_aors_1_t fudge (mpn_aors_1_t);
void
verify (const char *name, int i,
        mp_srcptr src, mp_limb_t n,
        mp_limb_t got_c, mp_limb_t want_c,
        mp_srcptr got, mp_srcptr want, mp_size_t size)
{
  if (got[size] != 0x1234)
    {
      printf ("Overwrite at %s i=%d\n", name, i);
      abort ();
    }
  if (got_c != want_c)
    {
      printf ("Wrong at %s i=%d size=%ld\n", name, i, size);
      abort ();
    }
}
void
check_add_1 (void)
{
  static const struct {
    mp_size_t size;
    mp_limb_t n;
    const mp_limb_t src[10];
    mp_limb_t want_c;
    const mp_limb_t want[10];
  } data[] = {
    { 1, 0, { 0 }, 0, { 0 } },
  };
  mp_limb_t got[10];
  mp_limb_t got_c;
  int i;
  for (i = 0; i < (sizeof (data) / sizeof ((data)[0])); i++)
    {
      got_c = __gmpn_add_1 (got, data[i].src, data[i].size, data[i].n);
      do { verify ("check_add_1 (separate)", i, data[i].src, data[i].n, got_c,
data[i].want_c, got, data[i].want, data[i].size); } while (0);
    }
}
void
check_sub_1 (void)
{
  static const struct {
    mp_size_t size;
    mp_limb_t n;
    const mp_limb_t src[10];
    mp_limb_t want_c;
    const mp_limb_t want[10];
  } data[] = {
    { 1, 0, { 0 }, 0, { 0 } },
  };
  mp_limb_t got[10];
  mp_limb_t got_c;
  int i;
  for (i = 0; i < (sizeof (data) / sizeof ((data)[0])); i++)
    {
      got_c = __gmpn_sub_1 (got, data[i].src, data[i].size, data[i].n);
      do { verify ("check_sub_1 (separate)", i, data[i].src, data[i].n, got_c,
data[i].want_c, got, data[i].want, data[i].size); } while (0);
    }
}
mpn_aors_1_t
fudge (mpn_aors_1_t f)
{
  return f;
}
int
main (void)
{
  check_add_1 ();
  check_sub_1 ();
  return 0;
}


-- 
           Summary: -finline-small-functions related oops
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dps at simpson dot demon dot co dot uk
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43997


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/43997] -finline-small-functions related oops
  2010-05-05 22:02 [Bug middle-end/43997] New: -finline-small-functions related oops dps at simpson dot demon dot co dot uk
@ 2010-05-05 22:05 ` dps at simpson dot demon dot co dot uk
  2010-05-05 22:47 ` [Bug middle-end/43997] [4.6 Regression] " falk at debian dot org
  2010-05-06  3:58 ` hjl dot tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dps at simpson dot demon dot co dot uk @ 2010-05-05 22:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dps at simpson dot demon dot co dot uk  2010-05-05 22:04 -------
Created an attachment (id=20573)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20573&action=view)
code for test case 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43997


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/43997] [4.6 Regression] -finline-small-functions related oops
  2010-05-05 22:02 [Bug middle-end/43997] New: -finline-small-functions related oops dps at simpson dot demon dot co dot uk
  2010-05-05 22:05 ` [Bug middle-end/43997] " dps at simpson dot demon dot co dot uk
@ 2010-05-05 22:47 ` falk at debian dot org
  2010-05-06  3:58 ` hjl dot tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: falk at debian dot org @ 2010-05-05 22:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from falk at debian dot org  2010-05-05 22:46 -------
Confirmed, here is a smaller testcase:

extern inline 
void add_1(int *dst, const int *src, int n) {
  if (n)
    dst[n] = src[n];
}

typedef void (*aors_1_t)(int *, const int *, int);

aors_1_t fudge(aors_1_t f) {
  return f;
}

void check_add_1 (int *dst, const int *src, int n) {
  fudge(add_1)(dst, src, n);
  fudge(add_1)(dst, src, n);
}


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
            Summary|-finline-small-functions    |[4.6 Regression] -finline-
                   |related oops                |small-functions related oops


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43997


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/43997] [4.6 Regression] -finline-small-functions related oops
  2010-05-05 22:02 [Bug middle-end/43997] New: -finline-small-functions related oops dps at simpson dot demon dot co dot uk
  2010-05-05 22:05 ` [Bug middle-end/43997] " dps at simpson dot demon dot co dot uk
  2010-05-05 22:47 ` [Bug middle-end/43997] [4.6 Regression] " falk at debian dot org
@ 2010-05-06  3:58 ` hjl dot tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-05-06  3:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl dot tools at gmail dot com  2010-05-06 03:57 -------


*** This bug has been marked as a duplicate of 43791 ***


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43997


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-06  3:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-05 22:02 [Bug middle-end/43997] New: -finline-small-functions related oops dps at simpson dot demon dot co dot uk
2010-05-05 22:05 ` [Bug middle-end/43997] " dps at simpson dot demon dot co dot uk
2010-05-05 22:47 ` [Bug middle-end/43997] [4.6 Regression] " falk at debian dot org
2010-05-06  3:58 ` hjl dot tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).