Bug 51552 - bfin generates bad assembly
Summary: bfin generates bad assembly
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Richard Henderson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-14 18:38 UTC by Joel Sherrill
Modified: 2011-12-21 20:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-12-17 00:00:00


Attachments
Preprocessed test case (5.39 KB, application/x-bzip)
2011-12-14 18:38 UTC, Joel Sherrill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Sherrill 2011-12-14 18:38:23 UTC
Created attachment 26085 [details]
Preprocessed test case

xgcc (GCC) 4.7.0 20111214 (experimental) [trunk revision 182330]
Target: bfin-rtems4.11 compiling newlib

/home2/joel/build/b-bfin-gcc/./gcc/xgcc -B/home2/joel/build/b-bfin-gcc/./gcc/ -nostdinc -B/home2/joel/build/b-bfin-gcc/bfin-rtems4.11/newlib/ -isystem /home2/joel/build/b-bfin-gcc/bfin-rtems4.11/newlib/targ-include -isystem /users/joel/test-gcc/gcc-svn/newlib/libc/include -B/users/joel/test-gcc/install-svn/bfin-rtems4.11/bin/ -B/users/joel/test-gcc/install-svn/bfin-rtems4.11/lib/ -isystem /users/joel/test-gcc/install-svn/bfin-rtems4.11/include -isystem /users/joel/test-gcc/install-svn/bfin-rtems4.11/sys-include    -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.19.0\" -DPACKAGE_STRING=\"newlib\ 1.19.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I/users/joel/test-gcc/gcc-svn/newlib/libc/string -D_COMPILING_NEWLIB -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN -Wall -fno-builtin      -g -O2 -c -o lib_a-strsignal.o `test -f 'strsignal.c' || echo '/users/joel/test-gcc/gcc-svn/newlib/libc/string/'`strsignal.c
/tmp/cctEZ5VY.s: Assembler messages:
/tmp/cctEZ5VY.s:24: Error: syntax error. Input text was .LCFI1.
/tmp/cctEZ5VY.s:24: Error: 

Cutting this down, it appears to be the -g flag:


[joel@rtbf64a string]$ /home2/joel/build/b-bfin-gcc/./gcc/xgcc -B/home2/joel/build/b-bfin-gcc/./gcc/ -O2 -c -fno-builtin j.c
[joel@rtbf64a string]$ /home2/joel/build/b-bfin-gcc/./gcc/xgcc -B/home2/joel/build/b-bfin-gcc/./gcc/ -O2 -c -g -fno-builtin j.c
/tmp/ccwaXpNe.s: Assembler messages:
/tmp/ccwaXpNe.s:24: Error: syntax error. Input text was .LCFI1.
/tmp/ccwaXpNe.s:24: Error: 

The bad asm generated is here:

.LCFI0:
        R2 = ROT R0 BY 0 ||
.LCFI1:
        R7 = [P2] ||
        nop;

I am guessing there should have been a semi-colon and maybe a nop before .LCFI1.
Comment 1 Jie Zhang 2011-12-17 03:06:37 UTC
This was caused by r177218 for PR target/49864.
Comment 2 Jie Zhang 2011-12-21 04:35:19 UTC
(gdb) p insn
$23 = (rtx) 0x7ffff701b180
(gdb) pr
(parallel [
        (unspec [
                (const_int -4 [0xfffffffffffffffc])
            ] 5)
        (set/f (mem:SI (plus:SI (reg/f:SI 14 SP)
                    (const_int -4 [0xfffffffffffffffc])) [0 S4 A32])
            (reg:SI 7 R7))
        (set/f (reg/f:SI 14 SP)
            (plus:SI (reg/f:SI 14 SP)
                (const_int -4 [0xfffffffffffffffc])))

Before that commit, dwarf2out_frame_debug_expr (insn) will set any_cfis_emitted in dwarf2out_frame_debug, which will cause dwarf2out_flush_queued_reg_saves to emit the CFI. But after that commit, dwarf2out_frame_debug_expr (insn) will not set any_cfis_emitted.
Comment 3 Richard Henderson 2011-12-21 17:51:30 UTC
Well, honestly the largest problem is that the bfin backend is
emitting bundles in a way that can't be split, but in separate insns.

The ia64 backend handles this case by supporting "debug labels"
in the assembler, which are understood not to break the bundle.

As far as the middle-end is concerned, it's doing absolutely nothing
wrong. I'll see what I can do to restore the kinda-sorta working state
that we had before, but you really ought to fix the backend to not
lie to the middle-end.

Consider implementing debug labels in the assembler.  Or failing
that, pack your insn bundles into sequences, or something.
Comment 4 Richard Henderson 2011-12-21 18:12:39 UTC
Mine.  The only thing I'll concede is that this is a debug size
regression from 4.6, as there's an unnecessary advance between
the two cfi opcodes.
Comment 5 Richard Henderson 2011-12-21 20:21:14 UTC
Author: rth
Date: Wed Dec 21 20:21:00 2011
New Revision: 182604

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182604
Log:
PR target/51552
        * dwarf2cfi.c (dwarf2out_frame_debug): Move any_cfis_emitted code...
        (scan_trace): ... here.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2cfi.c
Comment 6 Richard Henderson 2011-12-21 20:35:52 UTC
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01577.html