public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
@ 2015-05-21  3:04 hjl.tools at gmail dot com
  2015-05-21  3:42 ` [Bug target/66232] " hjl.tools at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-21  3:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66232
           Summary: -fPIC -fno-plt -mx32 fails to generate indirect branch
                    via GOT
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: ubizjak at gmail dot com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

[hjl@gnu-tools-1 plt-1]$ cat x.i
extern void bar (void);

void
foo (void)
{
  bar ();
}
[hjl@gnu-tools-1 plt-1]$ make
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -O2 -fPIC -fno-plt -mx32 -S
x.i
[hjl@gnu-tools-1 plt-1]$ cat x.s
        .file   "x.i"
        .section        .text.unlikely,"ax",@progbits
.LCOLDB0:
        .text
.LHOTB0:
        .p2align 4,,15
        .globl  foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        movl    bar@GOTPCREL(%rip), %eax
        jmp     *%rax
        .cfi_endproc
.LFE0:
        .size   foo, .-foo
        .section        .text.unlikely
.LCOLDE0:
        .text
.LHOTE0:
        .ident  "GCC: (GNU) 6.0.0 20150521 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-tools-1 plt-1]$ 

We should generate

jmp     *bar@GOTPCREL(%rip)

since GOT slot is 64-bit.


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
@ 2015-05-21  3:42 ` hjl.tools at gmail dot com
  2015-05-21 12:08 ` hjl.tools at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-21  3:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
We can add patterns to support

(call (mem:QI (zero_extend:DI (mem/u/c:SI (const:SI (unspec:SI [
                            (symbol_ref:SI ("bar") [flags 0x41]  <function_decl
0x7f19fd7bbbd0 bar>)
                        ] UNSPEC_GOTPCREL)) [1  S4 A8])) [0 bar S1 A8])
    (const_int 0 [0]))

It is "call *bar@GOTPCREL(%rip)"


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
  2015-05-21  3:42 ` [Bug target/66232] " hjl.tools at gmail dot com
@ 2015-05-21 12:08 ` hjl.tools at gmail dot com
  2015-05-21 15:31 ` hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-21 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
Created attachment 35585
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35585&action=edit
A patch

I am testing this.


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
  2015-05-21  3:42 ` [Bug target/66232] " hjl.tools at gmail dot com
  2015-05-21 12:08 ` hjl.tools at gmail dot com
@ 2015-05-21 15:31 ` hjl.tools at gmail dot com
  2015-05-21 21:59 ` hjl at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-21 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H.J. Lu from comment #2)
> Created attachment 35585 [details]
> A patch
> 
> I am testing this.

It failed this:

[hjl@gnu-6 pr66232]$ cat x.c
extern void (*bar) (void);
void
foo (int n)
{
  int i;
  for (i = 0; i < n; i++)
    {
      if (!bar)
        continue;
      (*bar) ();
    }
}
[hjl@gnu-6 pr66232]$ make
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc -fPIC -O -mx32 -S -o x.s x.c
x.c: In function ‘foo’:
x.c:12:1: error: unable to generate reloads for:
 }
 ^
(call_insn 17 15 18 5 (call (mem:QI (zero_extend:DI (reg/f:SI 87 [ D.1845 ]))
[0 *_6 S1 A8])
        (const_int 0 [0])) x.c:10 651 {*call_x32}
     (expr_list:REG_DEAD (reg/f:SI 87 [ D.1845 ])
        (nil))
    (nil))
x.c:12:1: internal compiler error: in curr_insn_transform, at
lra-constraints.c:3488
0xcf0c1e _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        /export/gnu/import/git/sources/gcc/gcc/rtl-error.c:110
0xbc6dec curr_insn_transform
        /export/gnu/import/git/sources/gcc/gcc/lra-constraints.c:3488
0xbc9c6c lra_constraints(bool)
        /export/gnu/import/git/sources/gcc/gcc/lra-constraints.c:4436
0xbb6074 lra(_IO_FILE*)
        /export/gnu/import/git/sources/gcc/gcc/lra.c:2317
0xb64a10 do_reload
        /export/gnu/import/git/sources/gcc/gcc/ira.c:5412
0xb64dbe execute
        /export/gnu/import/git/sources/gcc/gcc/ira.c:5583
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.
make: *** [x.s] Error 1
[hjl@gnu-6 pr66232]$
>From gcc-bugs-return-486974-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 21 15:38:21 2015
Return-Path: <gcc-bugs-return-486974-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 97276 invoked by alias); 21 May 2015 15:38:20 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 97146 invoked by uid 48); 21 May 2015 15:38:15 -0000
From: "mikael at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/66089] [6 Regression] elemental dependency mishandling when derived types are involved
Date: Thu, 21 May 2015 15:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mikael at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66089-4-URBRx2WTFx@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66089-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66089-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-05/txt/msg01814.txt.bz2
Content-length: 247

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf089

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to vehre from comment #7)
> Ah, ok, which opens the question why that isn't done?

Performance, for (very) big arrays.


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2015-05-21 15:31 ` hjl.tools at gmail dot com
@ 2015-05-21 21:59 ` hjl at gcc dot gnu.org
  2015-05-21 22:00 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl at gcc dot gnu.org @ 2015-05-21 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Thu May 21 21:58:57 2015
New Revision: 223505

URL: https://gcc.gnu.org/viewcvs?rev=223505&root=gcc&view=rev
Log:
Allow indirect branch via GOT slot for x32

X32 doesn't support indirect branch via 32-bit memory slot since
indirect branch will load 64-bit address from 64-bit memory slot.
Since x32 GOT slot is 64-bit, we should allow indirect branch via GOT
slot for x32.

gcc/

        PR target/66232
        * config/i386/constraints.md (Bg): New constraint for GOT memory
        operand.
        * config/i386/i386.md (*call_got_x32): New pattern.
        (*call_value_got_x32): Likewise.
        * config/i386/predicates.md (GOT_memory_operand): New predicate.

gcc/testsuite/

        PR target/66232
        * gcc.target/i386/pr66232-1.c: New test.
        * gcc.target/i386/pr66232-2.c: Likewise.
        * gcc.target/i386/pr66232-3.c: Likewise.
        * gcc.target/i386/pr66232-4.c: Likewise.
        * gcc.target/i386/pr66232-5.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr66232-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-2.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-3.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-4.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-5.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/constraints.md
    trunk/gcc/config/i386/i386.md
    trunk/gcc/config/i386/predicates.md
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2015-05-21 21:59 ` hjl at gcc dot gnu.org
@ 2015-05-21 22:00 ` hjl.tools at gmail dot com
  2015-07-27 16:25 ` hjl at gcc dot gnu.org
  2015-08-16 20:18 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-21 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |6.0

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed.


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2015-05-21 22:00 ` hjl.tools at gmail dot com
@ 2015-07-27 16:25 ` hjl at gcc dot gnu.org
  2015-08-16 20:18 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl at gcc dot gnu.org @ 2015-07-27 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Mon Jul 27 16:24:35 2015
New Revision: 226254

URL: https://gcc.gnu.org/viewcvs?rev=226254&root=gcc&view=rev
Log:
Add more tests for PR target/66232

        PR target/66232
        * gcc.target/i386/pr66232-6.c: New tests.
        * gcc.target/i386/pr66232-7.c: Likewise.
        * gcc.target/i386/pr66232-8.c: Likewise.
        * gcc.target/i386/pr66232-9.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr66232-6.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-7.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-8.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-9.c
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/66232] -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
  2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2015-07-27 16:25 ` hjl at gcc dot gnu.org
@ 2015-08-16 20:18 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-08-16 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2015-08-16
         Resolution|FIXED                       |---
     Ever confirmed|0                           |1

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
It fails with

# make check-gcc RUNTESTFLAGS="--target_board='unix{-mx32\
-maddress-mode=long}' i386.exp=pr66232-*.c"
...
FAIL: gcc.target/i386/pr66232-1.c scan-assembler jmp[ \t]*.bar@GOTPCREL
FAIL: gcc.target/i386/pr66232-2.c scan-assembler call[ \t]*.bar@GOTPCREL
FAIL: gcc.target/i386/pr66232-3.c scan-assembler jmp[ \t]*.bar@GOTPCREL
FAIL: gcc.target/i386/pr66232-4.c scan-assembler call[ \t]*.bar@GOTPCREL


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

end of thread, other threads:[~2015-08-16 20:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21  3:04 [Bug target/66232] New: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT hjl.tools at gmail dot com
2015-05-21  3:42 ` [Bug target/66232] " hjl.tools at gmail dot com
2015-05-21 12:08 ` hjl.tools at gmail dot com
2015-05-21 15:31 ` hjl.tools at gmail dot com
2015-05-21 21:59 ` hjl at gcc dot gnu.org
2015-05-21 22:00 ` hjl.tools at gmail dot com
2015-07-27 16:25 ` hjl at gcc dot gnu.org
2015-08-16 20:18 ` hjl.tools at gmail dot com

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).