[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-09 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #13 from Segher Boessenkool  ---
Fixed on trunk.  The comment 9 and comment 10 patches probably should be
backported.

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-09 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #12 from Segher Boessenkool  ---
Author: segher
Date: Wed May  9 12:51:00 2018
New Revision: 260077

URL: https://gcc.gnu.org/viewcvs?rev=260077&root=gcc&view=rev
Log:
rs6000: Give an argument to every REG_CFA_REGISTER (PR85645)

The one for the prologue mflr did not have any value set, which means
use the SET that is in the insn pattern.  This works fine, except when
some late pass decides to replace the SET_SRC -- this changes the
meaning of the REG_CFA_REGISTER!  Such passes should not do these
things, but let's be more explicit here, for extra robustness.  It
could be argued that this defaulting is a design misfeature (it does
not save much space either, etc.)


PR rtl-optimization/85645
* config/rs6000/rs6000.c (rs6000_emit_prologue_components): Put a SET
in the REG_CFA_REGISTER note for LR, don't leave it empty.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/rs6000.c

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-09 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #11 from Segher Boessenkool  ---
Author: segher
Date: Wed May  9 12:48:43 2018
New Revision: 260076

URL: https://gcc.gnu.org/viewcvs?rev=260076&root=gcc&view=rev
Log:
shrink-wrap: Improve spread_components (PR85645)

In the testcase for PR85645 we do a pretty dumb placement of the
prologue/epilogue for the LR component: we place an epilogue for LR
before a control flow split where one of the branches clobbers LR
eventually, and the other does not.  The branch that does clobber it
will need a prologue again some time later.  Because saving and
restoring LR is a two step process---it needs to be moved via a GPR---
the backend emits CFI directives so that we get correct unwind
information.  But both regcprop and regrename do not properly handle
such CFI directives leading to ICEs.

Now, neither of the two branches needs to have LR restored at all,
because both of the branches end up in an infinite loop.

This patch makes spread_component return a boolean saying if anything
was changed, and if so, it is called again.  This obviously is finite
(there is a finite number of basic blocks, each with a finite number
of components, and spread_components can only assign more components
to a block, never less).  I also instrumented the code, and on a
bootstrap+regtest spread_components made changes a maximum of two
times.  Interestingly though it made changes on two iterations in
a third of the cases it did anything at all!


PR rtl-optimization/85645
* shrink-wrap.c (spread_components): Return a boolean saying if
anything was changed.
(try_shrink_wrapping_separate): Iterate spread_components until
nothing changes anymore.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/shrink-wrap.c

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-09 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #10 from Segher Boessenkool  ---
Author: segher
Date: Wed May  9 12:14:39 2018
New Revision: 260075

URL: https://gcc.gnu.org/viewcvs?rev=260075&root=gcc&view=rev
Log:
regrename: Don't rename the dest of a REG_CFA_REGISTER (PR85645)

We should never change the destination of a REG_CFA_REGISTER, just
like for insns with a REG_CFA_RESTORE, because we need to have the
same control flow information on all branches that join.  It is very
doubtful that renaming the scratch registers used for prologue/epilogue
will help anything either.


PR rtl-optimization/85645
* regrename.c (build_def_use): Also kill the chains that include the
destination of a REG_CFA_REGISTER note.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/regrename.c

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-09 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #9 from Segher Boessenkool  ---
Author: segher
Date: Wed May  9 12:12:33 2018
New Revision: 260074

URL: https://gcc.gnu.org/viewcvs?rev=260074&root=gcc&view=rev
Log:
regcprop: Avoid REG_CFA_REGISTER notes (PR85645)

Changing a SET that has a REG_CFA_REGISTER note is wrong if we are
changing the SET_DEST, or if the REG_CFA_REGISTER has nil as its
argument, and maybe some other cases.  It's never really useful to
propagate into such an instruction, so let's just bail whenever we
see such a note.


PR rtl-optimization/85645
*  regcprop.c (copyprop_hardreg_forward_1): Don't propagate into an
insn that has a REG_CFA_REGISTER note.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/regcprop.c

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-05 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #8 from Segher Boessenkool  ---
Started at r259672.

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #7 from Segher Boessenkool  ---
Or actually, rnreg is the culprit (it was reg 0, rnreg moved this to reg 25)?

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #6 from Segher Boessenkool  ---
It goes wrong in cprop_hardreg, which replaces

insn/f 482 43 483 5 (set (reg:SI 25 25)
(reg:SI 65 lr)) 502 {*movsi_internal1}
 (expr_list:REG_DEAD (reg:SI 65 lr)
(expr_list:REG_CFA_REGISTER (nil)
(nil

by

(insn/f 482 43 483 5 (set (reg:SI 25 25)
(reg:SI 27 27 [65])) 502 {*movsi_internal1}
 (expr_list:REG_DEAD (reg:SI 65 lr)
(expr_list:REG_CFA_REGISTER (nil)
(nil

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #5 from Segher Boessenkool  ---
   saw edge from trace 1 to 4 (via jump_insn 42)

...

Processing trace 3 : start at code_label 507
   saw edge from trace 3 to 4 (via fallthru 0)
Inconsistent CFI state!
SHOULD have:
.cfi_def_cfa 1, 96
DO have:
.cfi_def_cfa 1, 96
.cfi_register 27, 25

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

Segher Boessenkool  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-05-04
 Ever confirmed|0   |1

--- Comment #4 from Segher Boessenkool  ---
~/build/tot/gcc/cc1 -quiet -Wall -W 85645.c -mcpu=powerpc -O1 -funroll-loops
-fno-dce -fno-tree-dominator-opts -fno-tree-fre -m32

fails for me.  Confirmed.

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

Jakub Jelinek  changed:

   What|Removed |Added

 CC||segher at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
./cc1 -quiet -nostdinc -m32 -mcpu=e300c2 -O1 -funroll-loops -fno-dce
-fno-tree-dominator-opts -fno-tree-fre -w pr85645.c
./cc1 -quiet -nostdinc -m32 -mcpu=powerpc -O1 -funroll-loops -fno-dce
-fno-tree-dominator-opts -fno-tree-fre -w pr85645.c
./cc1 -quiet -nostdinc -m32 -mcpu=power4 -O1 -funroll-loops -fno-dce
-fno-tree-dominator-opts -fno-tree-fre -w pr85645.c
./cc1 -quiet -nostdinc -m32 -mcpu=power5 -O1 -funroll-loops -fno-dce
-fno-tree-dominator-opts -fno-tree-fre -w pr85645.c
./cc1 -quiet -nostdinc -m32 -mcpu=power6 -O1 -funroll-loops -fno-dce
-fno-tree-dominator-opts -fno-tree-fre -w pr85645.c
all work, tried also -fpie, -fpic, -fasynchronous-unwind-tables -g,
-msecure-plt.
I'm simply out of ideas how to reproduce this.

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread asolokha at gmx dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

--- Comment #2 from Arseny Solokha  ---
One remarkable thing about this testcase is that in my setup it makes gcc ICE
w/ almost any valid argument to -mcpu. gcc successfully compiles it only w/
-mcpu={power6,power6x,power7,power8,power9,powerpc64le}. gcc for powerpcspe
target compiles it as well.

Should I attach my gcc/auto-host.h?

% powerpc-e300c3-linux-gnu-gcc-9.0.0-alpha20180429 -v
Using built-in specs.
COLLECT_GCC=powerpc-e300c3-linux-gnu-gcc-9.0.0-alpha20180429
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/lto-wrapper
Target: powerpc-e300c3-linux-gnu
Configured with:
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20180429/work/gcc-9-20180429/configure
--host=x86_64-pc-linux-gnu --target=powerpc-e300c3-linux-gnu
--build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/powerpc-e300c3-linux-gnu/gcc-bin/9.0.0-alpha20180429
--includedir=/usr/lib/gcc/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/include
--datadir=/usr/share/gcc-data/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429
--mandir=/usr/share/gcc-data/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/man
--infodir=/usr/share/gcc-data/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/info
--with-gxx-include-dir=/usr/lib/gcc/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/include/g++-v9
--with-python-dir=/share/gcc-data/powerpc-e300c3-linux-gnu/9.0.0-alpha20180429/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --disable-nls --enable-checking=yes --disable-esp
--enable-libstdcxx-time --enable-poison-system-directories
--with-sysroot=/usr/powerpc-e300c3-linux-gnu --disable-bootstrap
--enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec
--disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp
--disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx
--disable-vtable-verify --disable-libvtv --disable-libquadmath --enable-lto
--with-isl --disable-isl-version-check --disable-libsanitizer
Thread model: posix
gcc version 9.0.0-alpha20180429 20180429 (experimental) (GCC)

[Bug rtl-optimization/85645] ICE in maybe_record_trace_start, at dwarf2cfi.c:2348

2018-05-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85645

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
Can't reproduce with a cross-compiler.