Bug 41679 - [4.5 Regression] internal compiler error: in loc_cmp, at var-tracking.c:2433
Summary: [4.5 Regression] internal compiler error: in loc_cmp, at var-tracking.c:2433
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
Keywords: ice-on-valid-code
Depends on:
Reported: 2009-10-12 06:27 UTC by Kedar Sovani
Modified: 2009-12-17 20:57 UTC (History)
3 users (show)

See Also:
Target: armv5tel-unknown-linux-gnueabi, arm-eabi
Known to work:
Known to fail:
Last reconfirmed: 2009-11-10 10:36:34

The pre-processed sources files generated by gcc (34.33 KB, application/octet-stream)
2009-10-12 06:29 UTC, Kedar Sovani

Note You need to log in before you can comment on or make changes to this bug.
Description Kedar Sovani 2009-10-12 06:27:32 UTC
The entire build logs are available at:

This uses the Fedora gcc rpm 4.4.1-16

Initially I thought this to be the same as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41252. But the gcc sources already had the patch indicated in that bug (http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151437)
Comment 1 Kedar Sovani 2009-10-12 06:29:00 UTC
Created attachment 18785 [details]
The pre-processed sources files generated by gcc

Including the pre-processed sources file generated by gcc.
Comment 2 Jakub Jelinek 2009-10-12 07:12:58 UTC
Bugs regarding redhat/gcc-4_*-branch should be filed into bugzilla.redhat.com, not here.  That said, 4.4.1-16 is quite old, first try the latest one.
Comment 3 Jakub Jelinek 2009-11-09 17:36:24 UTC
/* { dg-do compile } */
/* { dg-options "-march=armv5te -g -O2" } */

extern int a;
extern char b;
extern int foo (void);

test (void)
  int c;
  b = foo () ? '~' : '\0';
  while ((c = foo ()))
    if (c == '7')
      a = 0;

fails on the current trunk the same way, at least in the x86_64-linux -> armv5tel-unknown-linux-gnueabi cross.
Comment 4 Jakub Jelinek 2009-11-09 18:42:02 UTC
(insn 78 77 16 2 rh528639.i:12 (cond_exec (eq (reg:CC 24 cc)
            (const_int 0 [0x0]))
        (set (reg:SI 0 r0 [orig:133 iftmp.0 ] [133])
            (reg:SI 4 r4))) 2367 {neon_vornv2di+77} (expr_list:REG_DEAD (reg:CC 24 cc)
we have MO_VAL_SET with 
(concat/v (concat:SI (value/s/u:SI 23753 @0x121b8f0/0x11da460)
        (reg:SI 0 r0 [orig:133 iftmp.0 ] [133]))
    (set (reg:QI 0 r0 [ iftmp.0 ])
        (reg:QI 4 r4)))

The QImode comes from the realdecl being tracked being actually QImode, so var_lowpart is called on the SET_SRC.  VAL_NEEDS_RESOLUTION is true, so
val_resolve (out, val, SET_SRC (uloc), insn); is called which sets a QImode r4
as one of the locations for the VALUE:SI 23753.  Then
5309		      val_store (out, val, vloc, insn);
is called, and vloc here is SImode, so we have non-matching modes.  Not sure where the bug is, maybe vloc should be QImode as well in that case and var_lowpart wasn't being called somewhere...

BTW, I wonder how well var-tracking.c handles COND_EXEC, I don't see it ever mentioned in var-tracking.c, so I assume it handles all the stores as unconditional.
Comment 5 Ramana Radhakrishnan 2009-11-10 10:36:34 UTC
Testcase in Comment #3 fails with -march=armv5te on arm-eabi cross on an x86_64-linux-gnu host with trunk.
Comment 7 Kedar Sovani 2009-12-09 13:29:00 UTC
Applied the three patches. These DO fix the issue mentioned above.

Is it safe to continue using these patches in gcc until the next stable release arrives?
Comment 8 Jakub Jelinek 2009-12-17 19:31:10 UTC
Subject: Bug 41679

Author: jakub
Date: Thu Dec 17 19:30:58 2009
New Revision: 155322

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155322
	PR debug/41679
	* var-tracking.c (add_stores): Avoid value mode mismatch for
	promoted declarations.

	* gcc.target/arm/pr41679.c: New.


Comment 9 Jakub Jelinek 2009-12-17 19:32:07 UTC
Subject: Bug 41679

Author: jakub
Date: Thu Dec 17 19:31:52 2009
New Revision: 155323

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155323
	PR debug/41679
	* var-tracking.c (use_type): Remove indirection from loc.
	(count_uses): Dereference incoming loc early.
	(add_uses): Dereference incoming loc early.


Comment 10 Jakub Jelinek 2009-12-17 19:32:43 UTC
Subject: Bug 41679

Author: jakub
Date: Thu Dec 17 19:32:32 2009
New Revision: 155324

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155324
	PR debug/41679
	* var-tracking.c (count_uses): Count MO_VAL_USE of original
	MO_VAL_SET value for COND_EXEC.
	(add_stores): Handle conditional stores.


Comment 11 Jakub Jelinek 2009-12-17 20:57:30 UTC