public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/65416] New: xtensa: memory allocated by alloca is used before the stack pointer is updated
@ 2015-03-13 12:24 jcmvbkbc at gcc dot gnu.org
  2015-03-13 14:58 ` [Bug target/65416] " jcmvbkbc at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2015-03-13 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65416
           Summary: xtensa: memory allocated by alloca is used before the
                    stack pointer is updated
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jcmvbkbc at gcc dot gnu.org

Created attachment 35025
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35025&action=edit
preprocessed source with a single function that demonstrates the issue

Hi,

I'm building gcc for xtensa linux. The function 'fork_inferior' has the
following fragment:

      argv = (char **) alloca (4 * sizeof (char *));
      argv[0] = shell_file;
      argv[1] = "-c";
      argv[2] = shell_command;
      argv[3] = (char *) 0;

that gcc compiles into this:

        addi    a3, sp, -32 
        l32r    a4, .LC23 
        s32i.n  a2, a3, 8 
        movi.n  a2, 0 
        s32i.n  a2, a3, 12 
        l32r    a2, .LC26 
        s32i.n  a3, a4, 0 
        l32i.n  a4, a7, 0 
        l32i.n  a2, a2, 0 
        s32i.n  a4, a3, 0 
        l32r    a4, .LC25 
        s32i.n  a2, a7, 20 
        l32i.n  a10, a7, 24 
        l32r    a2, .LC27 
        movsp   sp, a3 

Here argv is a3. The space below the stack pointer is used before the stack
pointer is updated.

This is reproducible with gcc-4.8.3 and the current 5.0 mainline.

Command line:
xtensa-buildroot-linux-uclibc-gcc -mlongcalls -mtext-section-literals -pipe -Os
-S -o fork-child.s fork-child.i

Compilers:

Using built-in specs.
COLLECT_GCC=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/bin/xtensa-buildroot-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/libexec/gcc/xtensa-buildroot-linux-uclibc/4.8.3/lto-wrapper
Target: xtensa-buildroot-linux-uclibc
Configured with: ./configure --prefix=/home/jcmvbkbc/tmp/br/build-xea3/host/usr
--sysconfdir=/home/jcmvbkbc/tmp/br/build-xea3/host/etc --enable-static
--target=xtensa-buildroot-linux-uclibc
--with-sysroot=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/xtensa-buildroot-linux-uclibc/sysroot
--disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib
--with-gmp=/home/jcmvbkbc/tmp/br/build-xea3/host/usr
--with-mpfr=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --enable-target-optspace
--disable-libsanitizer --disable-tls --disable-libmudflap --enable-threads
--with-mpc=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --without-isl
--without-cloog --disable-decimal-float --with-pkgversion='Buildroot
2014.08-00004-ge3e7af8' --with-bugurl=http://bugs.buildroot.net/
--enable-languages=c,c++
--with-build-time-tools=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/xtensa-buildroot-linux-uclibc/bin
--enable-shared --disable-libgomp
Thread model: posix
gcc version 4.8.3 (Buildroot 2014.08-00004-ge3e7af8) 

and

Using built-in specs.
COLLECT_GCC=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root/bin/xtensa-buildroot-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root/libexec/gcc/xtensa-buildroot-linux-uclibc/5.0.0/lto-wrapper
Target: xtensa-buildroot-linux-uclibc
Configured with: ../gcc/configure
--prefix=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root
--target=xtensa-buildroot-linux-uclibc --disable-shared --disable-libssp
--disable-libisl --enable-languages=c,c++
--with-sysroot=/home/jcmvbkbc/tmp/br/build-dejagnu-windowed/host/usr/xtensa-buildroot-linux-uclibc/sysroot
--disable-threads --disable-tls
Thread model: single
gcc version 5.0.0 20150303 (experimental) (GCC)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/65416] xtensa: memory allocated by alloca is used before the stack pointer is updated
  2015-03-13 12:24 [Bug target/65416] New: xtensa: memory allocated by alloca is used before the stack pointer is updated jcmvbkbc at gcc dot gnu.org
@ 2015-03-13 14:58 ` jcmvbkbc at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2015-03-13 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from jcmvbkbc at gcc dot gnu.org ---
It's ok up to sched2 pass, but sched2 does the following to it:

;;   ======================================================
;;   -- basic block 62 from 252 to 295 -- after reload
;;   ======================================================

;;        0--> b  0: i 253 a3=[`*.LC13']                           :nothing
;;        1--> b  0: i 252 a10=a2                                  :nothing
;;        2--> b  0: i 254 a10=call [a3]                           :nothing
;;        3--> b  0: i 257 a11=[`*.LC22']                          :nothing
;;        4--> b  0: i 259 a3=[`*.LC13']                           :nothing
;;        5--> b  0: i 258 a10=a2                                  :nothing
;;        6--> b  0: i 260 a10=call [a3]                           :nothing
;;        7--> b  0: i 261 a11=[a7+0x4]                            :nothing
;;        8--> b  0: i 262 a10=a2                                  :nothing
;;        9--> b  0: i 264 a10=call [a3]                           :nothing
;;       10--> b  0: i 265 a3=sp-0x20                              :nothing
;;       11--> b  0: i 271 a4=[`*.LC23']                           :nothing
;;       12--> b  0: i 276 [a3+0x8]=a2                             :nothing
;;       13--> b  0: i 277 a2=0                                    :nothing
;;       14--> b  0: i 278 [a3+0xc]=a2                             :nothing
;;       15--> b  0: i 279 a2=[`*.LC26']                           :nothing
;;       16--> b  0: i 272 [a4]=a3                                 :nothing
;;       17--> b  0: i 626 a4=[a7]                                 :nothing
;;       18--> b  0: i 280 a2=[a2]                                 :nothing
;;       19--> b  0: i 273 [a3]=a4                                 :nothing
;;       20--> b  0: i 274 a4=[`*.LC25']                           :nothing
;;       21--> b  0: i 627 [a7+0x14]=a2                            :nothing
;;       22--> b  0: i 281 a10=[a7+0x18]                           :nothing
;;       23--> b  0: i 282 a2=[`*.LC27']                           :nothing
;;       24--> b  0: i 625 sp=a3                                   :nothing
;;       25--> b  0: i 275 [a3+0x4]=a4                             :nothing
;;       26--> b  0: i 283 call [a2]                               :nothing
;;       27--> b  0: i 285 a2=[`*.LC28']                           :nothing
;;       29--> b  0: i 286 a10=[a2]                                :nothing
;;       30--> b  0: i 287 a2=[`*.LC29']                           :nothing
;;       32--> b  0: i 288 call [a2]                               :nothing
;;       33--> b  0: i 290 a3=[`*.LC30']                           :nothing
;;       35--> b  0: i 291 a10=[a3]                                :nothing
;;       37--> b  0: i 293 call [a2]                               :nothing
;;       38--> b  0: i 628 a2=[a7+0x10]                            :nothing
;;       39--> b  0: i 302 a10=[`*.LC31']                          :nothing
;;       40--> b  0: i 295 pc={(a2==0)?L657:pc}                    :nothing
;;      Ready list (final):  
;;   total time = 40
;;   new head = 253
;;   new tail = 295


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-13 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 12:24 [Bug target/65416] New: xtensa: memory allocated by alloca is used before the stack pointer is updated jcmvbkbc at gcc dot gnu.org
2015-03-13 14:58 ` [Bug target/65416] " jcmvbkbc at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).