From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29163 invoked by alias); 5 May 2010 22:02:31 -0000 Received: (qmail 26960 invoked by uid 48); 5 May 2010 22:02:01 -0000 Date: Wed, 05 May 2010 22:02:00 -0000 Subject: [Bug middle-end/43997] New: -finline-small-functions related oops X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dps at simpson dot demon dot co dot uk" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-05/txt/msg00506.txt.bz2 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 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