Bug 40599 - [4.5 regression] GCC error in pre_and_rev_post_order_compute, at cfganal.c:1045
Summary: [4.5 regression] GCC error in pre_and_rev_post_order_compute, at cfganal.c:1045
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: EH, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-06-30 10:28 UTC by Oliver Kellogg
Modified: 2009-11-10 05:38 UTC (History)
3 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
source files for reproducing the bug (331.44 KB, application/x-compressed-tar)
2009-06-30 10:34 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Kellogg 2009-06-30 10:28:54 UTC
$ gcc -c -g -O -v pkg0017.adb
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.5-20090625/configure --prefix=/opt/gnat/fsf --enable-languages=c,c++,ada --enable-debug
Thread model: posix
gcc version 4.5.0 20090625 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-g' '-O' '-v' '-mtune=generic'
 /opt/gnat/fsf/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/gnat1 -quiet -dumpbase pkg0017.adb -auxbase pkg0017 -O -g -mtune=generic pkg0017.adb -o /tmp/cc8cd7gb.s
+===========================GNAT BUG DETECTED==============================+
| 4.5.0 20090625 (experimental) (x86_64-unknown-linux-gnu) GCC error:      |
| in pre_and_rev_post_order_compute, at cfganal.c:1045                     |
| Error detected around pkg0017.adb:554:7                                  |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

pkg0017.adb
pkg0017.ads
pkg001b.ads
pkg0003.ads
pkg001c.ads
pkg000t.ads
pkg000w.ads
pkg000z.ads
pkg000y.ads
pkg001a.ads
pkg001g.ads
pkg0000.ads
pkg0015.ads
pkg001j.ads
pkg0001.ads
pkg0007.ads
pkg001d.ads
pkg0019.ads
pkg0006.ads
pkg000h.ads
pkg000g.ads
pkg000d.ads
pkg000f.ads
pkg000a.ads
pkg000e.ads
pkg0008.ads
pkg000c.ads
pkg000p.ads
pkg0004.ads
pkg000k.ads
pkg001q.ads
pkg000q.ads
pkg000j.ads
pkg001x.ads
pkg001y.ads
pkg000l.ads
pkg000n.ads
pkg000o.ads
pkg001k.ads
pkg001l.ads
pkg000m.ads
pkg001h.ads
pkg0014.ads
pkg0011.ads
pkg001e.ads
pkg0016.ads
pkg001p.ads
pkg0018.ads
pkg001f.ads
pkg0005.ads
pkg001i.ads
pkg0013.ads
pkg000x.ads
pkg0012.ads
pkg000v.ads
pkg0002.ads
pkg000u.ads
pkg0002.adb


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:415
Comment 1 Oliver Kellogg 2009-06-30 10:34:24 UTC
Created attachment 18099 [details]
source files for reproducing the bug

Tried this with i686-linux-gnu and x86_64-linux-gnu and with various
4.5.0 svn trunk versions of June up to 20090628.
Only happens when both -g and -O are switched on.
Comment 2 Oliver Kellogg 2009-06-30 10:49:19 UTC
Does not happen with 4.5.0 trunk 20090406 and earlier versions.
Comment 3 Richard Biener 2009-06-30 10:57:43 UTC
My bet would be var-tracking.  Can you try if -fno-var-tracking fixes this?
Comment 4 Oliver Kellogg 2009-06-30 11:06:57 UTC
> My bet would be var-tracking.  Can you try if -fno-var-tracking fixes this?

On the mark. Doesn't happen with -fno-var-tracking
Comment 5 Richard Biener 2009-07-02 11:37:47 UTC
Jakub should maybe know more ;)
Comment 6 Jakub Jelinek 2009-07-10 09:44:37 UTC
While this triggers only with -fvar-tracking, it is var-tracking related only in that vt_find_locations calls pre_and_rev_post_order_compute.  The real problem is that there are 2 basic blocks (in my case 220 and 222) that have no predecessors, so aren't reachable from the entry block and therefore
gcc_assert (pre_order_num == n_basic_blocks - NUM_FIXED_BLOCKS);
assertion fails (pre_order_num is n_basic_blocks - NUM_FIXED_BLOCKS - 2).

In *.split3 we have:

(insn 4396 853 4397 204 pkg0017.adb:483 (set (mem/c:SF (plus:DI (reg/f:DI 6 bp)
                (const_int -1668 [0xfffffffffffff97c])) [0 S4 A32])
        (reg:SF 21 xmm0 [orig:143 D.79246 ] [143])) 98 {*movsf_1} (expr_list:REG_DEAD (reg:SF 21 xmm0 [orig:143 D.79246 ] [143])
        (nil)))
(insn 4397 4396 854 204 pkg0017.adb:483 (set (reg:SF 8 st)
        (mem/c:SF (plus:DI (reg/f:DI 6 bp)
                (const_int -1668 [0xfffffffffffff97c])) [0 S4 A32])) 98 {*movsf_1} (nil))
(insn 854 4397 862 204 pkg0017.adb:483 (set (reg:XF 9 st(1) [orig:147 D.79250 ] [147])
        (float_extend:XF (reg:SF 8 st))) 137 {*extendsfxf2_i387} (expr_list:REG_DEAD (reg:SF 8 st)
        (expr_list:REG_EH_REGION (const_int 387 [0x183])
            (nil))))
;; End of basic block 204 -> ( 205 220)

...
;; Start of basic block ( 204) -> 220
;; bb 220 artificial_defs: { d-1(0){ }d-1(1){ }}
;; bb 220 artificial_uses: { u-1(6){ }u-1(7){ }u-1(16){ }u-1(20){ }}
;; lr  in        6 [bp] 7 [sp] 16 [argp] 20 [frame]
;; lr  use       6 [bp] 7 [sp] 16 [argp] 20 [frame]
;; lr  def       0 [ax] 1 [dx] 42 [r13]

;; Pred edge  204 (ab,eh)
(code_label 3492 4766 3497 220 941 "" [0 uses])

but in *.stack:

(insn 4396 853 4397 204 pkg0017.adb:483 (set (mem/c:SF (plus:DI (reg/f:DI 6 bp)
                (const_int -1668 [0xfffffffffffff97c])) [0 S4 A32])
        (reg:SF 21 xmm0 [orig:143 D.79246 ] [143])) 98 {*movsf_1} (expr_list:REG_DEAD (reg:SF 21 xmm0 [orig:143 D.79246 ] [143])
        (nil)))
(insn 4397 4396 862 204 pkg0017.adb:483 (set (reg:SF 8 st)
        (mem/c:SF (plus:DI (reg/f:DI 6 bp)
                (const_int -1668 [0xfffffffffffff97c])) [0 S4 A32])) 98 {*movsf_1} (nil))
;; End of basic block 204 -> ( 205)

...
;; Start of basic block () -> 220
;; bb 220 artificial_defs: { d-1(0){ }d-1(1){ }}
;; bb 220 artificial_uses: { u-1(6){ }u-1(7){ }u-1(16){ }u-1(20){ }}
;; lr  in        6 [bp] 7 [sp] 16 [argp] 20 [frame]
;; lr  use       6 [bp] 7 [sp] 16 [argp] 20 [frame]
;; lr  def       0 [ax] 1 [dx] 42 [r13]

(code_label 3492 4766 3497 220 941 "" [0 uses])

So, either the float_extend is considered throwing when it shouldn't (when would float_extend throw?  Only for signalling NaN?), or reg-stack.c is forgetting to cleanup the CFG when it removed insns with REG_EH_REGION.  In any case it definitely doesn't look like var-tracking.c's fault.
Comment 7 Oliver Kellogg 2009-07-12 04:41:08 UTC
> ------- Comment #2 From Oliver Kellogg  2009-06-30 10:49  [reply] -------
> 
> Does not happen with 4.5.0 trunk 20090406 and earlier versions.

Pardon, the version used was 20090314.
Does happen with 20090506 (r147182).
Building 20090406 r145578 now.
Comment 8 Oliver Kellogg 2009-07-12 05:28:58 UTC
> Building 20090406 r145578 now.

Does not happen there - problem must be between 20090406 and 20090506.
Does further narrowing down make sense?
Comment 9 Oliver Kellogg 2009-07-17 17:49:37 UTC
Triggered by
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146776
Comment 10 Richard Biener 2009-07-17 18:11:24 UTC
Honza, this is yours.
Comment 11 Richard Biener 2009-11-09 13:49:41 UTC
Does this still happen with current trunk, esp. after the EH rewrite?
Comment 12 Oliver Kellogg 2009-11-10 05:38:53 UTC
> Does this still happen with current trunk, esp. after the EH rewrite?

Does not happen with trunk r154034.
Thanks.