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

--- Comment #14 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Uroš Bizjak from comment #13)
> (In reply to H.J. Lu from comment #12)
> > Created attachment 34361 [details]
> > A new patch
> > 
> > Please try the new patch.
> 
> No, this approach is wrong. ix86_fixup_binary_operands should not be used to
> legitimize PIC address. The -fpic expansion is already wrong, since it
> produces:

> --cut here--
> typedef __SIZE_TYPE__ size_t;
> 
> extern char G[8];
> 
> char *a (size_t z)
> {
>   return &G[z];
> }
> --cut here--
> 
> Without -fpic, the compiler expands to:
> 
>     6: {r90:DI=r89:DI+`G';clobber flags:CC;}
> 
> Compare this with -fpic expansion:
> 
>     6: r92:DI=[const(unspec[`G'] 2)]
>     7: r91:DI=r92:DI
>       REG_EQUAL `G'
>     8: {r90:DI=r89:DI+r91:DI;clobber flags:CC;}
> 

This is generated in the backend:

Starting program: /export/build/gnu/gcc/build-x86_64-linux/gcc/cc1
-fpreprocessed /tmp/x.i -quiet -dumpbase x.i -mtune=generic -march=x86-64
-auxbase x -version -fPIC -o x.s
GNU C11 (GCC) version 5.0.0 20141228 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version
5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C11 (GCC) version 5.0.0 20141228 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version
5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: e92c7e019abbedeeeac36edef3dbfdca

Breakpoint 6, legitimize_pic_address (orig=0x7ffff19c8840, reg=0x0)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.c:13565
13565      rtx addr = orig;
(gdb) bt
#0  legitimize_pic_address (orig=0x7ffff19c8840, reg=0x0)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.c:13565
#1  0x0000000001082cf2 in ix86_expand_move (mode=DImode, 
    operands=0x7fffffffc840)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.c:17311
#2  0x00000000011a2c3f in gen_movdi (operand0=0x7ffff19c88b8, 
    operand1=0x7ffff19c8840)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.md:1938
#3  0x000000000084471f in insn_gen_fn::operator() (
    this=0x1a82330 <insn_data+201136>, a0=0x7ffff19c88b8, a1=0x7ffff19c8840)
    at /export/gnu/import/git/gcc/gcc/recog.h:303
#4  0x000000000091cb20 in emit_move_insn_1 (x=0x7ffff19c88b8, y=0x7ffff19c8840)
    at /export/gnu/import/git/gcc/gcc/expr.c:3529
#5  0x000000000091cf74 in emit_move_insn (x=0x7ffff19c88b8, y=0x7ffff19c8840)
    at /export/gnu/import/git/gcc/gcc/expr.c:3624
...
(gdb) call debug_rtx (orig)
(symbol_ref:DI ("G") [flags 0x40] <var_decl 0x7ffff189e900 G>)
(gdb)

Reply via email to