[Bug c/52253] New: wrong code generation

goweol at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 14 23:56:00 GMT 2012


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

             Bug #: 52253
           Summary: wrong code generation
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: goweol@gmail.com


If the x_wait() function is inlined, the block which contains memcpy() is
removed.

$  arm-none-eabi-gcc --version
arm-none-eabi-gcc (GCC) 4.6.2

$ uname -a
CYGWIN_NT-6.1-WOW64 namsh 1.7.10(0.259/5/3) 2012-02-05 12:36 i686 Cygwin

gcc configure option:
==============
$ /s/crosstool/gcc/configure --target=arm-none-eabi
--prefix=/s/crosstool/build/base --disable-nls --disable-werror
--enable-interwork --enable-multilib --disable-libssp --enable-languages=c,c++
--with-newlib --with-headers=/s/crosstool/newlib/newlib/libc/include
--with-system-zlib

command line option:
==============
$ arm-none-eabi-gcc -c -mcpu=cortex-m3  -mthumb -fomit-frame-pointer
-fverbose-asm -Wa,-ahlms=ex.lst -Os -fno-strength-reduce -o ex.o ex.c

The attached ex.c includes lines below:
#if 0
#define ATTR_NOINLINE __attribute__((__noinline__)) /* good result */
#else
#define ATTR_NOINLINE /* bad result */
#endif

And comment says all.

Generated list file with '#if 0' (bad).  There's no 'memcpy()' call.
==========================================
ARM GAS  /z/tmp/cc6WJdhu.s             page 1


   1                      .syntax unified
   2                      .cpu cortex-m3
   3                      .fpu softvfp
   4                      .eabi_attribute 20, 1
   5                      .eabi_attribute 21, 1
   6                      .eabi_attribute 23, 3
   7                      .eabi_attribute 24, 1
   8                      .eabi_attribute 25, 1
   9                      .eabi_attribute 26, 1
  10                      .eabi_attribute 30, 4
  11                      .eabi_attribute 18, 4
  12                      .file    "ex.c"
  13                  @ GNU C (GCC) version 4.6.2 (arm-none-eabi)
  14                  @    compiled by GNU C version 4.5.3, GMP version 4.3.2,
MPFR version 3.0.1-p4, MPC version 0.8
  15                  @ GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072
  16                  @ options passed:  -imultilib thumb -D__USES_INITFINI__
/d/ex.c
  17                  @ -mcpu=cortex-m3 -mthumb -auxbase-strip
.obj/oidd/src/ex.o -Os
  18                  @ -fomit-frame-pointer -fverbose-asm
  19                  @ options enabled:  -fauto-inc-dec -fbranch-count-reg
-fcaller-saves
  20                  @ -fcombine-stack-adjustments -fcommon -fcompare-elim
-fcprop-registers
  21                  @ -fcrossjumping -fcse-follow-jumps -fdefer-pop
  22                  @ -fdelete-null-pointer-checks -fdevirtualize
-fdwarf2-cfi-asm
  23                  @ -fearly-inlining -feliminate-unused-debug-types
-fexpensive-optimizations
  24                  @ -fforward-propagate -ffunction-cse -fgcse -fgcse-lm
  25                  @ -fguess-branch-probability -fident -fif-conversion
-fif-conversion2
  26                  @ -findirect-inlining -finline -finline-functions
  27                  @ -finline-functions-called-once -finline-small-functions
-fipa-cp
  28                  @ -fipa-profile -fipa-pure-const -fipa-reference
-fipa-sra
  29                  @ -fira-share-save-slots -fira-share-spill-slots -fivopts
  30                  @ -fkeep-static-consts -fleading-underscore -fmath-errno
-fmerge-constants
  31                  @ -fmerge-debug-strings -fmove-loop-invariants
-fomit-frame-pointer
  32                  @ -foptimize-register-move -foptimize-sibling-calls
-fpartial-inlining
  33                  @ -fpeephole -fpeephole2 -fprefetch-loop-arrays
-freg-struct-return
  34                  @ -fregmove -freorder-blocks -freorder-functions
-frerun-cse-after-loop
  35                  @ -fsched-critical-path-heuristic
-fsched-dep-count-heuristic
  36                  @ -fsched-group-heuristic -fsched-interblock
-fsched-last-insn-heuristic
  37                  @ -fsched-rank-heuristic -fsched-spec
-fsched-spec-insn-heuristic
  38                  @ -fsched-stalled-insns-dep -fschedule-insns2
-fsection-anchors
  39                  @ -fshow-column -fsigned-zeros -fsplit-ivs-in-unroller
-fsplit-wide-types
  40                  @ -fstrict-aliasing -fstrict-overflow
-fstrict-volatile-bitfields
  41                  @ -fthread-jumps -ftoplevel-reorder -ftrapping-math
-ftree-bit-ccp
  42                  @ -ftree-builtin-call-dce -ftree-ccp -ftree-ch
-ftree-copy-prop
  43                  @ -ftree-copyrename -ftree-cselim -ftree-dce
-ftree-dominator-opts
  44                  @ -ftree-dse -ftree-forwprop -ftree-fre
-ftree-loop-if-convert
  45                  @ -ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize
  46                  @ -ftree-parallelize-loops= -ftree-phiprop -ftree-pre
-ftree-pta
  47                  @ -ftree-reassoc -ftree-scev-cprop -ftree-sink
-ftree-slp-vectorize
  48                  @ -ftree-sra -ftree-switch-conversion -ftree-ter
-ftree-vect-loop-version
  49                  @ -ftree-vrp -funit-at-a-time -fverbose-asm
-fzero-initialized-in-bss
  50                  @ -mfix-cortex-m3-ldrd -mlittle-endian -msched-prolog
-mthumb
  51                  
  52                  @ Compiler executable checksum:
13e7fc7637be27d27d0c05bad08836a1
  53                  
  54                      .text
  55                      .align    1
  56                      .global    x_read
  57                      .thumb

ARM GAS  /z/tmp/cc6WJdhu.s             page 2


  58                      .thumb_func
  59                      .type    x_read, %function
  60                  x_read:
  61                      @ args = 0, pretend = 0, frame = 0
  62                      @ frame_needed = 0, uses_anonymous_args = 0
  63                      @ link register save eliminated.
  64 0000 054B             ldr    r3, .L5    @ tmp140,
  65 0002 0022             movs    r2, #0    @,
  66 0004 5A80             strh    r2, [r3, #2]    @ movhi    @, tbl.len
  67 0006 0222             movs    r2, #2    @ tmp144,
  68 0008 1A70             strb    r2, [r3, #0]    @ tmp144, tbl.xfer_dir
  69 000a 044A             ldr    r2, .L5+4    @ ivtmp.2,
  70                  .L3:
  71 000c 1978             ldrb    r1, [r3, #0]    @ zero_extendqisi2    @
tmp148,
  72 000e 09B1             cbz    r1, .L2    @ tmp148,
  73 0010 013A             subs    r2, r2, #1    @ ivtmp.2, ivtmp.2,
  74 0012 FBD1             bne    .L3    @,
  75                  .L2:
  76 0014 0020             movs    r0, #0    @,
  77 0016 7047             bx    lr    @
  78                  .L6:
  79                      .align    2
  80                  .L5:
  81 0018 00000000         .word    .LANCHOR0
  82 001c 404B4C00         .word    5000000
  83                      .size    x_read, .-x_read
  84                      .bss
  85                      .align    1
  86                      .set    .LANCHOR0,. + 0
  87                      .type    tbl, %object
  88                      .size    tbl, 260
  89                  tbl:
  90 0000 00000000         .space    260
  90      00000000 
  90      00000000 
  90      00000000 
  90      00000000 
  91                      .ident    "GCC: (GNU) 4.6.2"

ARM GAS  /z/tmp/cc6WJdhu.s             page 3


DEFINED SYMBOLS
                            *ABS*:00000000 ex.c
   /z/tmp/cc6WJdhu.s:55     .text:00000000 $t
   /z/tmp/cc6WJdhu.s:60     .text:00000000 x_read
   /z/tmp/cc6WJdhu.s:81     .text:00000018 $d
   /z/tmp/cc6WJdhu.s:85     .bss:00000000 $d
   /z/tmp/cc6WJdhu.s:89     .bss:00000000 tbl

NO UNDEFINED SYMBOLS



More information about the Gcc-bugs mailing list