This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

stack_pointer_delta related ICE in libgcc on 4.9.1


Trying to bootstrap m68k i hit an assert in emit_library_call_value_1
that wants to assure that the stack is aligned properly.

PUSH_ROUNDING(GET_MODE_SIZE(QImode)) for m5206 is currently 1 so
the testcase below has stack_pointer_delta = 1 + 1 + 4
but emit_library_call_value_1() has this:

  /* Stack must be properly aligned now.  */
  gcc_assert (!(stack_pointer_delta
                & (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT - 1)));

where 6 & 3 != 0 and ICEs

I am not familier with m68k so i would be glad for any help!

Should the arg be partial? Doesn't look like, no.
Does m68k use stack save area? From the looks it doesn't.
Is the alignment_pad for QImode arg wrong?
Should PUSH_ROUNDING be changed back to the !CF variant?
Or is the alignment assert too strict?
Perhaps m5206 is not TARGET_CAS and should not compile this linux-atomic
in the first place?

(is emit_library_call_value_1 missing a do_pending_stack_adjust() before
NO_DEFER_POP ? Does not seem relevant for this case though)

Slightly simplified reproducer:

$ cat x.i ; echo "EOF"; # see libgcc/config/m68k/linux-atomic.c
unsigned char
  __attribute__ ((visibility ("hidden")))
__sync_val_compare_and_swap_1 (unsigned char *ptr, unsigned char soldval,
			       unsigned char snewval)
{
  unsigned *wordptr = (unsigned *) ((unsigned long) ptr & ~3);
  unsigned int mask, shift, woldval, wnewval;
  unsigned oldval, newval, cmpval;
  shift = (((unsigned long) ptr & 3) << 3) ^ 24;
  mask = 0xffu << shift;
  woldval = (soldval & 0xffu) << shift;
  wnewval = (snewval & 0xffu) << shift;
  cmpval = *wordptr;
  do
    {
      oldval = cmpval;
      if ((oldval & mask) != woldval)
	break;
      newval = (oldval & ~mask) | wnewval;
      {
	register unsigned *a0 asm ("a0") = wordptr;
	register unsigned d2 asm ("d2") = oldval;
	register unsigned d1 asm ("d1") = newval;
	register unsigned d0 asm ("d0") = 335;
	asm volatile ("trap #0":"=r" (d0), "=r" (d1), "=r" (a0):"r" (d0),
		      "r" (d1), "r" (d2), "r" (a0):"memory", "a1");
	cmpval = d0;
      }
    }
  while (__builtin_expect (oldval != cmpval, 0));
  return (oldval >> shift) & 0xffu;
}

_Bool
  __attribute__ ((visibility ("hidden")))
__sync_bool_compare_and_swap_1 (unsigned char *ptr, unsigned char oldval,
				unsigned char newval)
{
  return (__sync_val_compare_and_swap_1 (ptr, oldval, newval) == oldval);
}
EOF


/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin/m68k-oe-linux.gcc-cross-initial-m68k/m68k-oe-linux-gcc  -mcpu=5206 --sysroot=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/qemum68k -O2 -pipe -g -feliminate-unused-debug-types -O2  -g -Os -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fPIC -I. -I. -I/home/me/src/oe/openembedded-core/build/tmp-glibc/work/m5206-oe-linux/libgcc-initial/4.9.1-r0/gcc-4.9.1/build.m68k-oe-linux.m68k-oe-linux/m68k-oe-linux/libgcc/../.././gcc -I/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc -I/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/. -I/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../gcc -I/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../include  -DHAVE_CC_TLS  -o o.o -MT linux-atomic.i -MD -MP -MF linux-atomic.dep  -c x.i -fvisibility=hidden -DHIDE_EXPORTS -v
Using built-in specs.
COLLECT_GCC=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin/m68k-oe-linux.gcc-cross-initial-m68k/m68k-oe-linux-gcc
Target: m68k-oe-linux
Configured with: /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/configure --build=x86_64-linux --host=x86_64-linux --target=m68k-oe-linux --prefix=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr --exec_prefix=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr --bindir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin/m68k-oe-linux.gcc-cross-initial-m68k --sbindir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin/m68k-oe-linux.gcc-cross-initial-m68k --libexecdir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/libexec/m68k-oe-linux.gcc-cross-initial-m68k --datadir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/share --sysconfdir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/etc --sharedstatedir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/com --localstatedir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/var --libdir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/lib/m68k-oe-linux.gcc-cross-initial-m68k --includedir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/include --oldincludedir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/include --infodir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/share/info --mandir=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux 'CFLAGS_FOR_TARGET=-O0 -g3 -ggdb3' 'CXXFLAGS_FOR_TARGET=-O0 -g3 -ggdb3' --enable-stage1-checking=yes,all,types,rtl --with-newlib --without-headers --disable-shared --disable-threads --disable-multilib --disable-__cxa_atexit --enable-languages=c --program-prefix=m68k-oe-linux- --with-sysroot=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/qemum68k --with-build-sysroot=/home/me/src/oe/openembedded-core/build/tmp-glibc/work/x86_64-oe-linux/gcc-cross-initial-m68k/4.9.1-r0/gcc-4.9.1/build.x86_64-linux.m68k-oe-linux/tmpsysroot --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --with-system-zlib --disable-lto --disable-plugin --enable-decimal-float=no --with-native-system-header-dir=/usr/include --disable-nls --enable-__cxa_atexit
Thread model: single
gcc version 4.9.1 (GCC) 
COLLECT_GCC_OPTIONS='--sysroot=/home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/qemum68k' '-mcpu=5206' '-O2' '-pipe' '-g' '-feliminate-unused-debug-types' '-O2' '-g' '-Os' '-D' 'IN_GCC' '-D' 'CROSS_DIRECTORY_STRUCTURE' '-Wextra' '-Wall' '-Wno-narrowing' '-Wwrite-strings' '-Wcast-qual' '-Wstrict-prototypes' '-Wmissing-prototypes' '-Wold-style-definition' '-isystem' './include' '-g' '-D' 'IN_LIBGCC2' '-fbuilding-libgcc' '-fno-stack-protector' '-D' 'inhibit_libc' '-fPIC' '-I' '.' '-I' '.' '-I' '/home/me/src/oe/openembedded-core/build/tmp-glibc/work/m5206-oe-linux/libgcc-initial/4.9.1-r0/gcc-4.9.1/build.m68k-oe-linux.m68k-oe-linux/m68k-oe-linux/libgcc/../.././gcc' '-I' '/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc' '-I' '/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/.' '-I' '/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../gcc' '-I' '/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../include' '-D' 'HAVE_CC_TLS' '-o' 'o.o' '-MT' 'linux-atomic.i' '-MD' '-MP' '-MF' 'linux-atomic.dep' '-c' '-fvisibility=hidden' '-D' 'HIDE_EXPORTS' '-v'
 /home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/libexec/m68k-oe-linux.gcc-cross-initial-m68k/gcc/m68k-oe-linux/4.9.1/cc1 -fpreprocessed x.i -isysroot /home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/qemum68k -quiet -dumpbase x.i -mcpu=5206 -auxbase-strip o.o -g -g -g -O2 -O2 -Os -Wextra -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -version -feliminate-unused-debug-types -fbuilding-libgcc -fno-stack-protector -fPIC -fvisibility=hidden -o - |
 /home/me/src/oe/openembedded-core/build/tmp-glibc/sysroots/x86_64-linux/usr/libexec/m68k-oe-linux.gcc-cross-initial-m68k/gcc/m68k-oe-linux/4.9.1/as -v -I . -I . -I /home/me/src/oe/openembedded-core/build/tmp-glibc/work/m5206-oe-linux/libgcc-initial/4.9.1-r0/gcc-4.9.1/build.m68k-oe-linux.m68k-oe-linux/m68k-oe-linux/libgcc/../.././gcc -I /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc -I /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/. -I /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../gcc -I /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/libgcc/../include -mcpu=5206 --pcrel -o o.o
GNU assembler version 2.24 (m68k-oe-linux) using BFD version (GNU Binutils) 2.24
GNU C (GCC) version 4.9.1 (m68k-oe-linux)
	compiled by GNU C version 4.7.2, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.9.1 (m68k-oe-linux)
	compiled by GNU C version 4.7.2, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fab8bdf6ebfc97a6ab2021160771c16d
x.i: In function '__sync_bool_compare_and_swap_1':
x.i:39:11: internal compiler error: in emit_library_call_value_1, at calls.c:4187
   return (__sync_val_compare_and_swap_1 (ptr, oldval, newval) == oldval);
           ^
0x512e60 emit_library_call_value_1
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/calls.c:4186
0x513452 emit_library_call_value(rtx_def*, rtx_def*, libcall_type, machine_mode, int, ...)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/calls.c:4369
0x7dac47 expand_atomic_compare_and_swap(rtx_def**, rtx_def**, rtx_def*, rtx_def*, rtx_def*, bool, memmodel, memmodel)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/optabs.c:7476
0x4ed0ab expand_builtin_compare_and_swap
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/builtins.c:5188
0x4ef778 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/builtins.c:6522
0x61a391 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:10327
0x6130ce expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:7950
0x60ce1e store_expr(tree_node*, rtx_def*, int, bool)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:5336
0x60c47b expand_assignment(tree_node*, tree_node*, bool)
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:5122
0x52073b expand_call_stmt
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:2273
0x522c16 expand_gimple_stmt_1
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:3170
0x5230ff expand_gimple_stmt
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:3322
0x527edc expand_gimple_basic_block
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:5162
0x52938d gimple_expand_cfg
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:5741
0x5299d8 execute
	/home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/cfgexpand.c:5961
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


(gdb) watch stack_pointer_delta
Hardware watchpoint 2: stack_pointer_delta
(gdb) c
Continuing.
GNU C (GCC) version 4.9.1 (m68k-oe-linux)
	compiled by GNU C version 4.7.2, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fab8bdf6ebfc97a6ab2021160771c16d
Hardware watchpoint 2: stack_pointer_delta

Old value = 0
New value = 1
emit_single_push_insn_1 (mode=QImode, x=0x7ffff6d86e88, type=0x0)
    at /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:4014
4014	  icode = optab_handler (push_optab, mode);
(gdb) c
Continuing.
Hardware watchpoint 2: stack_pointer_delta

Old value = 1
New value = 2
emit_single_push_insn_1 (mode=QImode, x=0x7ffff6d86e58, type=0x0)
    at /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:4014
4014	  icode = optab_handler (push_optab, mode);
(gdb) c
Continuing.
Hardware watchpoint 2: stack_pointer_delta

Old value = 2
New value = 6
emit_single_push_insn_1 (mode=SImode, x=0x7ffff6d89480, type=0x0)
    at /home/me/src/oe/openembedded-core/build/tmp-glibc/work-shared/gcc-4.9.1-r0/gcc-4.9.1/gcc/expr.c:4014
4014	  icode = optab_handler (push_optab, mode);

thanks,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]