Bug 25023 - [4.1/4.2 Regression] ICE in def_cfa_1, at dwarf2out.c:792
Summary: [4.1/4.2 Regression] ICE in def_cfa_1, at dwarf2out.c:792
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.1.0
: P3 critical
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
: 25293 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-24 16:54 UTC by Richard Biener
Modified: 2005-12-13 20:16 UTC (History)
4 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-24 20:03:43


Attachments
testcase (unreduced) (100.54 KB, text/plain)
2005-11-24 16:58 UTC, Richard Biener
Details
testcase (908 bytes, text/plain)
2005-11-24 17:04 UTC, Richard Biener
Details
gcc41-pr25293.patch (1.15 KB, patch)
2005-12-08 13:11 UTC, Jakub Jelinek
Details | Diff
gcc41-pr25023.patch (1.78 KB, patch)
2005-12-09 20:13 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2005-11-24 16:54:02 UTC
We fail to build the linux kernel on i686 with debugging enabled.

drivers/usb/media/w9968cf.c:

/usr/lib/gcc/i586-suse-linux/4.1.0/cc1 -fpreprocessed w9968cf.i -quiet -dumpbase w9968cf.i -m32 -msoft-float -mpreferred-stack-boundary=2 -march=i586 -mregparm=3 -auxbase-strip drivers/usb/media/.tmp_w9968cf.o -g -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wno-pointer-sign -version -fno-strict-aliasing -fno-common -ffreestanding -fomit-frame-pointer -fno-unit-at-a-time -o /tmp/ccaO9lCn.s
drivers/usb/media/w9968cf.c: In function ‘w9968cf_set_picture’:
drivers/usb/media/w9968cf.c:1827: internal compiler error: in def_cfa_1, at dwarf2out.c:792
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.suse.de/feedback> for instructions.

(reducing)
Comment 1 Richard Biener 2005-11-24 16:56:07 UTC
The candidate which likely broke it is

2005-11-17  Richard Henderson  <rth@redhat.com> 

        * dwarf2out.c (dw_cfi_oprnd_struct): Reduce dw_cfi_reg_num to int.
        (lookup_cfa_1): Apply data alignment to DW_CFA_def_cfa_offset_sf
        and DW_CFA_def_cfa_sf.
        (def_cfa_1): Use DW_CFA_def_cfa_offset_sf with negative values.
        (dbx_reg_number): Don't assert particular registers here.
        (based_loc_descr): ... do it here instead.  Fold in ...
        (eliminate_reg_to_offset): ... this function.
        (compute_frame_pointer_to_cfa_displacement): Fold in the effects
        of eliminate_reg_to_offset; use FRAME_POINTER_CFA_OFFSET.
        * unwind-dw2.c (execute_cfa_program): Apply data align factor
        to DW_CFA_def_cfa_offset_sf and DW_CFA_def_cfa_sf.
        * function.c (instantiate_new_reg): Use FRAME_POINTER_CFA_OFFSET.
        (instantiate_virtual_regs): Likewise.
        * var-tracking.c (adjust_stack_reference): Likewise.
        * doc/tm.texi (FRAME_POINTER_CFA_OFFSET): New.
Comment 2 Richard Biener 2005-11-24 16:58:51 UTC
Created attachment 10334 [details]
testcase (unreduced)

testacse
Comment 3 Richard Biener 2005-11-24 17:04:26 UTC
Created attachment 10335 [details]
testcase

reduced testcase
Comment 4 Andrew Pinski 2005-11-24 17:11:41 UTC
-O2 -m32 -msoft-float -mpreferred-stack-boundary=2 -march=i586 -mregparm=3 -fno-strict-aliasing -fno-common -ffreestanding -fomit-frame-pointer -fno-unit-at-a-time -g
Comment 5 Andrew Pinski 2005-11-24 20:03:42 UTC
Confirmed, the inline-asm is required (this testcase does not reduce any further really).
Comment 6 Andrew Pinski 2005-11-24 20:42:38 UTC
Here is a reduced testcase as far as I can get it:
struct device_driver {
   const char * name;
};
struct video_picture {
   unsigned  short a,b,c,d,e;
};
struct w9968cf_device {
   struct device_driver *driver;
   int vpp_flag;
};
int debug = 2;
int specific_debug = 0;
int w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
{
   short fmt, reg_v = 0x0000;
   int err = 0;
   long esi, edi;
   switch (fmt)  {
    case 13:
    reg_v |= 0x0002;
   case 4:
   case 5:
     cam->vpp_flag = 8;
   }
   if (err = w9968cf_write_reg(cam, reg_v, 0x16))
     if (err = w9968cf_sensor_update_picture(cam, pict))
        __asm__ __volatile__("movsw"    :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
  if (((specific_debug) && (debug == (1))) || ((!specific_debug) && (debug >= (1))))
    printk("<4>" "%s %s: " "Failed to change picture settings" "\n" ,  cam->driver->name );
   return err;
}
Comment 7 Andrew Pinski 2005-12-07 14:09:51 UTC
*** Bug 25293 has been marked as a duplicate of this bug. ***
Comment 8 Jakub Jelinek 2005-12-07 18:12:23 UTC
I believe negative CFA offsets that aren't a multiple of 4 aren't representable
in DWARF 3, so either we'd have to lie in the unwind info, or we shouldn't
be misaligning the stack pointer ever.
Comment 9 Richard Henderson 2005-12-07 18:21:48 UTC
Indeed we shouldn't be mis-aligning the stack pointer.  And if you look at
the actual assembly, we aren't.  Therefore the problem is bogus debug info.

I had been looking at this PR for a while, but got sidetracked.  I seem to
recall thinking that there was some sort of memory corruption going on.
Comment 10 Jakub Jelinek 2005-12-07 18:27:09 UTC
The stack is misaligned, though not at any call insn:
        subl    $2, %esp
        movl    40(%esp), %eax
        pushl   %eax
        movl    40(%esp), %eax
        pushl   %eax
        movl    40(%esp), %eax
        pushl   %eax
        movw    42(%esp), %di
        pushw   %di
        call    f2
Comment 11 Jakub Jelinek 2005-12-08 13:11:31 UTC
Created attachment 10439 [details]
gcc41-pr25293.patch

This patch disallows 16-bit pushes (similarly how x86_64 disallows
16-bit and 32-bit pushes).  I don't have an i586 to verify how slow pushw
is, but it would surprise me if it was fast.
Comment 12 Richard Henderson 2005-12-08 19:12:53 UTC
This patch is ok.
Comment 13 Richard Biener 2005-12-09 12:50:21 UTC
The patch breaks bootstrap on i686 linux:

/usr/src/packages/BUILD/gcc-4.1.0-20051209/obj-i586-suse-linux/./gcc/xgcc -B/usr/src/packages/BUILD/gcc-4.1.0-20051209/obj-i586-suse-linux/./gcc/ -B/usr/i586-suse-linux/bin/ -B/usr/i586-suse-linux/lib/ -isystem /usr/i586-suse-linux/include -isystem /usr/i586-suse-linux/sys-include -DHAVE_CONFIG_H -I. -I../../../libmudflap -I. -Wall -ffunction-sections -fdata-sections -O2 -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -U_FORTIFY_SOURCE -MT mf-runtime.lo -MD -MP -MF .deps/mf-runtime.Tpo -c ../../../libmudflap/mf-runtime.c  -fPIC -DPIC -o .libs/mf-runtime.o
../../../libmudflap/mf-runtime.c: In function '__mfu_check':
../../../libmudflap/mf-runtime.c:1032: error: unrecognizable insn:
(insn 1384 1383 1385 31 ../../../libmudflap/mf-runtime.c:1457 (set (mem:HI (pre_dec:SI (reg/f:SI 7 sp)) [0 S2 A8])
        (reg:HI 0 ax [orig:182 __mf_lc_shift ] [182])) -1 (nil)
    (nil))
../../../libmudflap/mf-runtime.c:1032: internal compiler error: in extract_insn, at recog.c:2084
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.suse.de/feedback> for instructions.
Comment 14 Jakub Jelinek 2005-12-09 20:13:33 UTC
Created attachment 10446 [details]
gcc41-pr25023.patch

A new version of the patch.  While this bootstraps (at least on i386 I tried),
I'm getting some regressions though, particularly:
FAIL: gcc.dg/compat/scalar-by-value-4 c_compat_x_tst.o compile
FAIL: gcc.dg/compat/scalar-by-value-4 c_compat_y_tst.o compile
FAIL: gcc.dg/compat/scalar-return-4 c_compat_x_tst.o compile
FAIL: gcc.dg/compat/scalar-return-4 c_compat_y_tst.o compile
FAIL: gcc.dg/compat/struct-by-value-11 c_compat_x_tst.o compile
FAIL: gcc.dg/compat/struct-by-value-11 c_compat_y_tst.o compile

All seem to be ICEs in emit_move_resolve_push (CQI, [
(mem/i:CQI (pre_modify:SI (reg/f:SI 7 sp)
        (plus:SI (reg/f:SI 7 sp)
            (const_int -4 [0xfffffffc]))) [0 S2 A8])
]), where that function only handles PRE_{INC,DEC} and POST_{INC,DEC}, but
not PRE_MODIFY.  Will see if just handling {PRE,POST}_MODIFY is the right thing
there or if something different is wrong.
Comment 15 Jakub Jelinek 2005-12-13 08:08:51 UTC
Subject: Bug 25023

Author: jakub
Date: Tue Dec 13 08:08:46 2005
New Revision: 108463

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108463
Log:
	PR debug/25023
	PR target/25293
	* expr.c (emit_move_resolve_push): Handle PRE_MODIFY
	and POST_MODIFY with CONST_INT adjustment equal to PUSH_ROUNDING.
	Fix POST_INC/POST_DEC handling if PUSH_ROUNDING is not identity.
	* config/i386/i386.md (pushhi2, pushqi2): Use pushl instead of pushw.
	Set mode to SI, adjust constraints.
	(pushhi2_rex64, pushqi2_rex64): Set mode to DI.
	* config/i386/i386.h (PUSH_ROUNDING): Round up to 4 instead of 2 for
	32-bit code.

	* gcc.target/i386/pr25293.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr25293.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.h
    trunk/gcc/config/i386/i386.md
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog

Comment 16 Jakub Jelinek 2005-12-13 08:17:22 UTC
Subject: Bug 25023

Author: jakub
Date: Tue Dec 13 08:17:18 2005
New Revision: 108468

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108468
Log:
	PR debug/25023
	PR target/25293
	* expr.c (emit_move_resolve_push): Handle PRE_MODIFY
	and POST_MODIFY with CONST_INT adjustment equal to PUSH_ROUNDING.
	Fix POST_INC/POST_DEC handling if PUSH_ROUNDING is not identity.
	* config/i386/i386.md (pushhi2, pushqi2): Use pushl instead of pushw.
	Set mode to SI, adjust constraints.
	(pushhi2_rex64, pushqi2_rex64): Set mode to DI.
	* config/i386/i386.h (PUSH_ROUNDING): Round up to 4 instead of 2 for
	32-bit code.

	* gcc.target/i386/pr25293.c: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.target/i386/pr25293.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/i386/i386.h
    branches/gcc-4_1-branch/gcc/config/i386/i386.md
    branches/gcc-4_1-branch/gcc/expr.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 17 Jakub Jelinek 2005-12-13 13:14:04 UTC
Should be fixed in CVS.
Comment 18 Andrew Pinski 2005-12-13 20:16:01 UTC
This is causing a bootstrap failure, the same as in comment #13 in fact.
Comment 19 Jakub Jelinek 2005-12-14 20:30:53 UTC
Subject: Bug 25023

Author: jakub
Date: Wed Dec 14 20:30:46 2005
New Revision: 108537

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108537
Log:
	PR debug/25023
	* config/i386/i386.c (ix86_force_to_memory): Always use
	SImode push for HImode in -m32.
	(ix86_free_from_memory): Likewise.

	* gcc.dg/pr25023.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr25023.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog

Comment 20 Jakub Jelinek 2005-12-14 20:38:41 UTC
Subject: Bug 25023

Author: jakub
Date: Wed Dec 14 20:38:31 2005
New Revision: 108539

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108539
Log:
	PR debug/25023
	* config/i386/i386.c (ix86_force_to_memory): Always use
	SImode push for HImode in -m32.
	(ix86_free_from_memory): Likewise.

	* gcc.dg/pr25023.c: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr25023.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/i386/i386.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog