[Bug c/56077] New: volatile ignored when function inlined

huntting at glarp dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 22 15:59:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56077

             Bug #: 56077
           Summary: volatile ignored when function inlined
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: huntting@glarp.com


The following code snipit produces incorrect code with -fno-schedule-insns2. 
The volatile assignments are incorrectly condensed, but only when the function
is inlined.

I observed similar behavior with the RX port of gcc (KPIT 12.02).


brad

---------------------------


DRACK-1$ cat x.c


static inline void
foo(volatile int *p)
{
    asm("#BEGIN");
    *p = 86;
    *p = 87;
    *p = 88;
    asm("#END");
}

void
bar(void)
{
    volatile int *p = (volatile int *)1234567;
    foo(p);
}
DRACK-1$ gcc -Wall -Wextra -fno-schedule-insns2 -O -c -save-temps /tmp/x.c &&
sed -n '/BEGIN/,/END/p' /tmp/x.s 
        #BEGIN
# 0 "" 2
#NO_APP
        movl    $86, 1234567
        movl    $87, 1234567
        movl    $88, 1234567
#APP
# 10 "/tmp/x.c" 1
        #END
DRACK-1$ gcc -Wall -Wextra -fschedule-insns2 -O -c -save-temps /tmp/x.c && sed
-n '/BEGIN/,/END/p' /tmp/x.s 
        #BEGIN
# 0 "" 2
#NO_APP
        movl    $88, 1234567
#APP
# 10 "/tmp/x.c" 1
        #END
DRACK-1$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 
DRACK-1$ cat /tmp/x.i
# 1 "/tmp/x.c"
# 1 "<command-line>"
# 1 "/tmp/x.c"


static inline void
foo(volatile int *p)
{
    asm("#BEGIN");
    *p = 86;
    *p = 87;
    *p = 88;
    asm("#END");
}

void
bar(void)
{
    volatile int *p = (volatile int *)1234567;
    foo(p);
}
DRACK-1$



More information about the Gcc-bugs mailing list