https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85035

            Bug ID: 85035
           Summary: nios2: adding -fdelete-null-pointer-checks with -O2
                    enabled
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rvdv at vandewiele dot com
  Target Milestone: ---

Created attachment 43732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43732&action=edit
source file

The code in attachment reads a 64 bit integer to compare it. 
When loading the first 32 bit, an instruction is used that bypasses the cache.
For the last 32 bit a regular load is used.

The -mno-cache-volatile option is supposed to bypass the cache for volatile
variables. But as you can see, no volatile variables are used in the example.

I have noticed that working code is generated when the
"-fdelete-null-pointer-checks" option is removed.
The O2 option should also enable "-fdelete-null-pointer-checks", so I would
expect the extra "-fdelete-null-pointer-checks" to be redundant. 
This doesn't seem to be the case.

Target: nios2-elf
Configured with: ../../src/gcc-7.3.0/configure --target=nios2-elf --with-newlib
--disable-threads --disable-shared --disable-multilib --disable-nls
--enable-languages=c,c++ --disable-libssp --enable-lto --without-headers
--prefix=/c/gcc/gcc7.3-src/nios2-elf-7.3.0 --with-isl --enable-plugins
Thread model: single
gcc version 7.3.0 (GCC)

build commad:
./7.3.0/bin/nios2-elf-gcc -O2 -fdelete-null-pointer-checks -mno-cache-volatile
-Wall -Wextra -fno-strict-aliasing -fwrapv -save-temps test.cpp -o test.elf

output:
c:/gcc/nios2-elf-mingw/7.3.0/bin/../lib/gcc/nios2-elf/7.3.0/../../../../nios2-elf/bin/ld.exe:
warning: cannot find entry symbol _start; defaulting to 000010dc

Reply via email to