foss-for-synopsys-dwc-arc-processors / toolchain

Repository containing releases of prebuilt GNU toolchains for DesignWare ARC Processors from Synopsys (available from "releases" link below).
http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/Pages/default.aspx
GNU General Public License v3.0
92 stars 48 forks source link

Internal Compiler Error on multiple inheritance. #647

Open alex-etched opened 1 week ago

alex-etched commented 1 week ago

The following code will ICE the compiler:

#include <cstddef>

#define NO_INLINE __attribute__((noinline))

class ParentA {
  virtual void Push() = 0;
};
class ParentB {
  virtual void Pop() = 0;
};
class Child : public ParentA, public ParentB {
  NO_INLINE void Push() {}
  NO_INLINE void Pop() {}
};

Child buffer;

int main() {

}

Compile command + flags:

arc64-elf-gcc app.cc -mcpu=hs6x -mfpu=none -m128 -mbbit -mbitscan -mbrcc -mcmodel=large -mcode-density
app.cc: In member function 'virtual void Child::_ZThn8_N5Child3PopEv()':
app.cc:20:1: internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1177
   20 | }
      | ^
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.

Version Info:

arc64-elf-gcc -v
Using built-in specs.
COLLECT_GCC=(redacted)
COLLECT_LTO_WRAPPER=(redacted)
Target: arc64-snps-elf
Configured with: /SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/.build/arc64-snps-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arc64-snps-elf --prefix=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/arc64-unknown-elf --exec_prefix=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/arc64-unknown-elf --with-local-prefix=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/arc64-unknown-elf/arc64-snps-elf --with-sysroot=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/arc64-unknown-elf/arc64-snps-elf --with-native-system-header-dir=/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='ARCv3 elf toolchain - build 6938' --enable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libstdcxx-verbose --with-gmp=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/.build/arc64-snps-elf/buildtools --with-mpfr=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/.build/arc64-snps-elf/buildtools --with-mpc=/SCRATCH/arcjenkins2/slaves/us01-odc-custom-arcoss1/workspace/arcoss_verification/arc_gnu_toolchain_verification/build_toolchain-12/crosstool-ng/.build/arc64-snps-elf/buildtools --with-isl=no --with-cloog=no --enable-lto --disable-nls --disable-tls --enable-multiarch --enable-languages=c,c++
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (ARCv3 elf toolchain - build 6938)

ccPL5RIM.out.zip

luismgsilva commented 4 days ago

The root issue appears to result from GCC generating indirect calls by first loading the callee's address into a register before executing the branch-and-link, as it's handling a long call. This forces to be created of a pseudo register. The complication arises because, at this stage of compilation, no additional pseudo registers can be generated.

While the patch is being verified and tested, a possible temporary workaround is to modify the compilation options by excluding the memory model option.

arc64-elf-gcc app.cc -mcpu=hs6x -mfpu=none -m128 -mbbit -mbitscan -mbrcc -mcode-density --specs=nsim.specs