Bug 50474 - GCC (cc1plus) hangs forever compiling with -O2 (-fcse-follow-jumps)
Summary: GCC (cc1plus) hangs forever compiling with -O2 (-fcse-follow-jumps)
Status: RESOLVED DUPLICATE of bug 50380
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2011-09-21 15:59 UTC by Steffen Schmidt
Modified: 2011-09-26 10:46 UTC (History)
1 user (show)

See Also:
Host: mingw-32
Target: mips-elf
Build:
Known to work:
Known to fail: 4.3.2, 4.4.1, 4.5.1, 4.6.0
Last reconfirmed:


Attachments
Source example (151 bytes, application/octet-stream)
2011-09-21 15:59 UTC, Steffen Schmidt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Schmidt 2011-09-21 15:59:52 UTC
Created attachment 25332 [details]
Source example

Compilation hangs forever in the following example when using optimization >= -O2
The option causing the hang seems to be -fcse-follow-jumps, when lowering optimization level or explicitly excluding the option cse-follow-jumps (-fno-cse-follow-jumps) compilation works as expected.

Compiler command line:
mips-sde-elf-gcc -O2 -c -oopterror.o opterror.cpp //<-- this hangs
mips-sde-elf-gcc -O2 -fno-cse-follow-jumps -c -oopterror.o opterror.cpp //<-- this works fine

//=================================
// File opterror.cpp
unsigned short global;
void get_R(unsigned char * data);

bool processFirstCall() {
    unsigned char r = 0; 
	get_R(&r);
    if(r != !!r) {
	  return false;
    }
    if(r) global = 1;
	return true;
}
//=================================


I was only able to reproduce this behavour on mips toolchains (4.3.2, 4.5.1, 4.6.0) provided by CodeSourcery and own compilation (MinGW32).

gcc -v shows:

Target: mips-sde-elf
Configured with: /scratch/clm/2011.03-sde-lite/src/gcc-4.5-2011.03/configure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=mips-sde-elf --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-arch=mips32r2 --enable-sgxx-sde-multilibs --disable-threads --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2011 -D__CS_SOURCERYGXX_MIN__=3 -D__CS_SOURCERYGXX_REV__=52 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --enable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2011.03-52' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/mips-sde-elf --with-build-sysroot=/scratch/clm/2011.03-sde-lite/install/host-i686-mingw32/mips-sde-elf --with-libiconv-prefix=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-gmp=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-mpfr=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-mpc=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-ppl=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --with-libelf=/scratch/clm/2011.03-sde-lite/obj/host-libs-2011.03-52-mips-sde-elf-i686-mingw32/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/clm/2011.03-sde-lite/obj/tools-i686-pc-linux-gnu-2011.03-52-mips-sde-elf-i686-mingw32/mips-sde-elf/bin --with-build-time-tools=/scratch/clm/2011.03-sde-lite/obj/tools-i686-pc-linux-gnu-2011.03-52-mips-sde-elf-i686-mingw32/mips-sde-elf/bin
Thread model: single
gcc version 4.5.2 (Sourcery G++ Lite 2011.03-52)
Comment 1 Richard Biener 2011-09-25 11:55:12 UTC
Please report this bug to CodeSourcery then.
Comment 2 Steffen Schmidt 2011-09-26 09:04:33 UTC
I'm very sorry for the inconvenience, but this bug is not directly related to any CodeSourcery built GCC toolchain. It was a pure coincedence using such a toolchain.

I am able to reproduce the effect with toolchain GCC 4.6.0 for MIPS built from source using MinGW:

Target: mips-siemens-elf
Configured with: ../../gcc-4.6.0/configure --enable-languages=c,c++ --with-arch=mips32r2 -enable-poison-system-directories --enable-interwork --enable-multilib --enable-sgxx-sde-multilibs --with-gcc --with-gnu-ld --with-gnu-as --with-stabs --disable-libmudflap --disable-libssp --disable-shared --disable-threads --disable-libgomp --disable-win32-registry --disable-nls --target=mips-siemens-elf --with-newlib --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --prefix=/build_mips_4.6.0_cloog/cross-gcc/mips-siemens-elf --with-gmp=/build_mips_4.6.0_cloog/host --with-mpfr=/build_mips_4.6.0_cloog/host --with-mpc=/build_mips_4.6.0_cloog/host --with-ppl=/build_mips_4.6.0_cloog/host --with-cloog=/build_mips_4.6.0_cloog/host --with-sysroot=/build_mips_4.6.0_cloog/cross-gcc/mips-siemens-elf
Thread model: single
gcc version 4.6.0 (GCC)

The behaviour seems to be related to the code line
if(r != !!r)

When replacing the condition with the equivalent
if(r != 0 && r != 1)

everything seems fine.

Is it worth investigating the issue further and re-open it?
Comment 3 Mikael Pettersson 2011-09-26 09:38:11 UTC
(In reply to comment #2)
> The behaviour seems to be related to the code line
> if(r != !!r)

This is clearly a dup of PR50380.
Comment 4 Richard Biener 2011-09-26 10:46:06 UTC
.

*** This bug has been marked as a duplicate of bug 50380 ***