[4.9 Regression] ICE in final_scan_insn, at final.c:2952 (aarch64-linux-gnu)

Bug #1353729 reported by Matthias Klose on 2014-08-06
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Linaro
Fix Released
Wishlist
gcc-4.8 (Ubuntu)
Undecided
Unassigned
gcc-4.9 (Ubuntu)
Medium
Unassigned

Bug Description

https://bugs.linaro.org/show_bug.cgi?id=331

seen with 4.9 linaro 2014.07, works with -O1

$ g++ -c -O2 -fPIE pfs_host.ii
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc: In function 'PFS_host* find_or_create_host(PFS_thread*, const char*, uint)':
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc:289:1: error: could not split insn
 }
 ^
(insn:TI 304 300 305 (parallel [
            (set (reg:SI 2 x2 [orig:153 D.16667 ] [153])
                (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32]))
            (set (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32])
                (unspec_volatile:SI [
                        (ior:SI (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32])
                            (const_int 0 [0]))
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 3 x3 [330]))
            (clobber (reg:SI 4 x4 [331]))
        ]) /home/doko/tmp/mysql-5.6-5.6.19/include/my_atomic.h:217 2338 {atomic_fetch_orsi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 4 x4 [331])
            (expr_list:REG_UNUSED (reg:SI 3 x3 [330])
                (nil)))))
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc:289:1: internal compiler error: in final_scan_insn, at final.c:2952
Please submit a full bug report,
with preprocessed source if appropriate.

Created attachment 92
preprocessed source

seen with 4.9 linaro 2014.07, works with -O1

$ g++ -c -O2 -fPIE pfs_host.ii
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc: In function 'PFS_host* find_or_create_host(PFS_thread*, const char*, uint)':
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc:289:1: error: could not split insn
 }
 ^
(insn:TI 304 300 305 (parallel [
            (set (reg:SI 2 x2 [orig:153 D.16667 ] [153])
                (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32]))
            (set (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32])
                (unspec_volatile:SI [
                        (ior:SI (mem/v:SI (reg/f:DI 1 x1 [orig:113 D.16671 ] [113]) [-1 S4 A32])
                            (const_int 0 [0]))
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 3 x3 [330]))
            (clobber (reg:SI 4 x4 [331]))
        ]) /home/doko/tmp/mysql-5.6-5.6.19/include/my_atomic.h:217 2338 {atomic_fetch_orsi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 4 x4 [331])
            (expr_list:REG_UNUSED (reg:SI 3 x3 [330])
                (nil)))))
/home/doko/tmp/mysql-5.6-5.6.19/storage/perfschema/pfs_host.cc:289:1: internal compiler error: in final_scan_insn, at final.c:2952
Please submit a full bug report,
with preprocessed source if appropriate.

Changed in gcc-4.9 (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed

Created attachment 104
Reduced preprocessed source code from the example above

The mentioned testcase can be reduced to 47 lines of code.
I cannot reduce anymore.

The error is similiar, but is somehow different from yours:

pfs_host.ii:47:1: error: could not split insn
 }
 ^
(insn:TI 71 72 73 (parallel [
            (set (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
                (unspec_volatile:SI [
                        (ior:SI (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
                            (const_int 0 [0]))
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 1 x1 [143]))
            (clobber (reg:SI 2 x2 [144]))
        ]) pfs_host.ii:32 2326 {atomic_orsi}
     (expr_list:REG_DEAD (reg/f:DI 19 x19 [117])
        (expr_list:REG_UNUSED (reg:CC 66 cc)
            (expr_list:REG_UNUSED (reg:SI 2 x2 [144])
                (expr_list:REG_UNUSED (reg:SI 1 x1 [143])
                    (nil))))))
pfs_host.ii:47:1: internal compiler error: in final_scan_insn, at final.c:2957
0xb2b8c5 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
 /home/ilya/cbuild2/build/snapshots/gcc.git/gcc/rtl-error.c:109
0x9030b1 final_scan_insn(rtx_def*, _IO_FILE*, int, int, int*)
 /home/ilya/cbuild2/build/snapshots/gcc.git/gcc/final.c:2957
0x903352 final(rtx_def*, _IO_FILE*, int)
 /home/ilya/cbuild2/build/snapshots/gcc.git/gcc/final.c:2027
0x903b52 rest_of_handle_final
 /home/ilya/cbuild2/build/snapshots/gcc.git/gcc/final.c:4453
0x903b52 execute
 /home/ilya/cbuild2/build/snapshots/gcc.git/gcc/final.c:4528
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.launchpad.net/gcc-linaro> for instructions.

The compiler fails after function split_insns (generaged from md) fails with the following arguments:

pattern =

(parallel [
        (set (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
            (unspec_volatile:SI [
                    (ior:SI (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
                        (const_int 0 [0]))
                    (const_int 5 [0x5])
                ] UNSPECV_ATOMIC_OP))
        (clobber (reg:CC 66 cc))
        (clobber (reg:SI 1 x1 [143]))
        (clobber (reg:SI 2 x2 [144]))
    ])

insn =

(insn:TI 71 72 73 (parallel [
            (set (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
                (unspec_volatile:SI [
                        (ior:SI (mem/v:SI (reg/f:DI 19 x19 [117]) [-1 S4 A32])
                            (const_int 0 [0]))
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 1 x1 [143]))
            (clobber (reg:SI 2 x2 [144]))
        ]) pfs_host.ii:32 2326 {atomic_orsi}
     (expr_list:REG_DEAD (reg/f:DI 19 x19 [117])
        (expr_list:REG_UNUSED (reg:CC 66 cc)
            (expr_list:REG_UNUSED (reg:SI 2 x2 [144])
                (expr_list:REG_UNUSED (reg:SI 1 x1 [143])
                    (nil))))))

(from gdb output of debug_rtx(pat) and debug_rtx(insn))

Created attachment 110
The patch that fixes error (maybe incorrect!)

The error is related with legacy built-in functions for atomic memory access
https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins

Such builtins are expanded to atomic_* instructions at expand pass.

It has been found that usually all atomic_* RTL instructions (except atomic_store*) are splitted out after pass split2 (you can check it by compiling sync-1.c from gcc testuite). So there must not be any atomic_* after split2 (except atomic_store*).
But in our case insn atomic_orsi was not splitted out after split2 and stayed in code till to the final pass.

Final pass also tries to split all instrutions, but it fails with assertion, if at least 1 insn can not be splitted.

So the first erroneous behavior appears at least at split2 pass.

It checks the operand of atomic_orsi, using function aarch64_logical_operand return false for 0.

In the attached patch i tried to allow aarch64_logical_operand to work with 0 case.

Is it correct?

James Page (james-page) wrote :

Matthias

Any update on this bug? This is currently blocking transition of mysql-5.6 to utopic release pocket due to a FTBFS on arm64.

Changed in linaro:
importance: Unknown → Wishlist
status: Unknown → New

Created attachment 155
2nd variant of reduced testcase

Since some commit the previous testcase compiles fine.

It's strange that 24 is the minimal constant for which the error occurs. If you change it to smaller value, the testcase can be compiled fine.

Matthias Klose (doko) wrote :

James, this shouldn't be a blocker. As mentioned in the bug description, -O1 on this file works around the issue.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.9 - 4.9.1-15ubuntu1

---------------
gcc-4.9 (4.9.1-15ubuntu1) utopic; urgency=medium

  * Merge with Debian; remaining changes:
    - Build from upstream sources.

gcc-4.9 (4.9.1-15) unstable; urgency=medium

  * Update to SVN 20140918 (r215344) from the gcc-4_9-branch.

  [ Matthias Klose ]
  * Extend the fix for PR target/63190 (AArch64). Closes: #758964.
  * Apply proposed fix for Linaro #331, LP: #1353729 (AArch64).

  [ Aurelien Jarno ]
  * Default to mips64 ISA on mips64el, with tuning for mips64r2.
 -- Matthias Klose <email address hidden> Fri, 19 Sep 2014 01:03:34 +0200

Changed in gcc-4.9 (Ubuntu):
status: Confirmed → Fix Released

I have created a fix for this bug that has been successfully tested by doko. I am validating the fix and will update the status as appropriate

Changed in linaro:
status: New → Unknown

Committed in upstream trunk as rev 217076.

Changed in linaro:
status: Unknown → Fix Released
dann frazier (dannf) wrote :

The gcc-4.8 SRU in trusty from 4.8.2-19ubuntu1 -> 4.8.4-2ubuntu1~14.04 has introduced this regression, causing mysql-5.6 to now FTBFS. I've confirmed that this bug also persists in gcc-4.8 in wily today (4.8.4-3ubuntu1).

Changed in gcc-4.8 (Ubuntu):
status: New → Confirmed

Hello Matthias, or anyone else affected,

Accepted mysql-5.6 into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/mysql-5.6/5.6.19-0ubuntu0.14.04.4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-needed
Steve Langasek (vorlon) wrote :

Hello Matthias, or anyone else affected,

Accepted gccgo-4.9 into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gccgo-4.9/4.9.3-0ubuntu4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Steve Langasek (vorlon) wrote :

This bug was not identified with gccgo, only with g++, which is not applicable to the in-progress gccgo-4.9 SRU. Marking as resolved.

tags: removed: verification-needed

The verification of the Stable Release Update for gccgo-4.9 has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.