public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiong Wang <jiong.wang@arm.com>
To: James Greenhalgh <james.greenhalgh@arm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	Alexander Monakov <amonakov@ispras.ru>
Subject: Re: [COMMITTED][AArch64][sibcall]Tighten direct call pattern to repair -fno-plt
Date: Fri, 07 Aug 2015 13:28:00 -0000	[thread overview]
Message-ID: <n99egjfrzwa.fsf@arm.com> (raw)
In-Reply-To: <20150807082242.GA4610@arm.com>

[-- Attachment #1: Type: text/plain, Size: 3410 bytes --]


James Greenhalgh writes:

> On Thu, Aug 06, 2015 at 05:16:33PM +0100, Jiong Wang wrote:
>
> Hi Jiong,
>
> The new testcases introduced in this and the related patch are failing
> for me on aarch64-none-elf:
>
>     aarch64-none-elf
>
> 	NA->FAIL: gcc.target/aarch64/noplt_1.c scan-assembler
> 	NA->FAIL: gcc.target/aarch64/noplt_2.c scan-assembler-times
> 	NA->FAIL: gcc.target/aarch64/noplt_3.c scan-assembler-times
>
> For this invocation:
>  
>   .../build/obj/gcc2/gcc/xgcc -B.../build/obj/gcc2/gcc/ .../src/gcc/testsuite/gcc.target/aarch64/noplt_1.c -fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -fno-plt -fpic -S  -mcmodel=small -o noplt_1.s
>
> I get this code generation for the small memory model:
>
> foo:
> 	stp	x29, x30, [sp, -32]!
> 	adrp	x1, _GLOBAL_OFFSET_TABLE_
> 	add	x29, sp, 0
> 	str	x19, [sp, 16]
> 	mov	w19, w0
> 	ldr	x0, [x1, #:gotpage_lo15:bar]
> 	blr	x0
> 	ldr	w0, [x0, w19, sxtw 2]
> 	ldr	x19, [sp, 16]
> 	ldp	x29, x30, [sp], 32
> 	ret
> 	.size	foo, .-foo
>
> Which uses a different relocation.
>
> Did you intend for these tests to be run with -fPIC -fno-plt rather than
> -fpic -fno-plt, or does this indicate a bug?
>
> Thanks,
> James


  Thanks for noticed this.

  As it's -fpic in dg-option, so they are supposed to work under -fpic,
  while I was checking the instruction sequences for -fPIC which is wrong.

  It's passed on my local machine because I was doing cross-check and
  there is no cross binutils installed, I only built cc1, then run the
  check. After double check I found actually all those scan-assemble
  test have not been triggered, because looks like the dejagnu was using
  local x86 assembler to do some prerequite check, then found -EL not
  supported, then those prerequite check returns false.

  Even worse, as -fpic for AArch64 will fall back to -fPIC if the
  installed aarch64 binutils don't support recently added relocation
  types for -fpic, so even I have wrote correct instruction sequences in
  this testcase, it will fail on those environment where old binutils
  installed, and... even new binutils installed, they may still fail if
  the user pre-configure gcc with -mabi=ilp32, as for ILP32, the
  relocation modifer for small code small for -fPIC is gotpage_14
  instead of gotpage_15 for LP64.

  Unfortunally, after all above considered, these testcases still fail
  if the user force -mcmodel=tiny to the compilation options, because
  those dejagnu target effective check will not know those extra options
  user added.

  After second think, I found my previous checking logic is not
  good. It's better we check the final branch type instead of be
  bothered by those relocation modifiers.

  Because the fundanmental changes -fno-plt bring us is it turn direct
  branch into indirect branch, then turn "bl/b" into "blr/br", while
  those GOT reloated modifers are just for preparing the branch
  destination register.

  Patch pass -fpic/-fPIC/binutils-without-fpic/binutils-with-fpic/ilp32.

  Should be OK now.

  Commited as obivious.

  Thanks.

  2015-08-07  Jiong Wang  <jiong.wang@arm.com>

  gcc/testsuite/
    * gcc.target/aarch64/noplt_1.c: Check branch type instead of
    relocation modifers.
    * gcc.target/aarch64/noplt_2.c: Likewise.
    * gcc.target/aarch64/noplt_3.c: Likewise.

-- 
Regards,
Jiong


[-- Attachment #2: fix.patch --]
[-- Type: text/x-diff, Size: 1737 bytes --]

diff --git a/gcc/testsuite/gcc.target/aarch64/noplt_1.c b/gcc/testsuite/gcc.target/aarch64/noplt_1.c
index 4e9bb62..731fcae 100644
--- a/gcc/testsuite/gcc.target/aarch64/noplt_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/noplt_1.c
@@ -11,5 +11,5 @@ foo (int a)
   return b[a];
 }
 
-/* { dg-final { scan-assembler "#:got:" { target { aarch64_tiny || aarch64_small } } } } */
-/* { dg-final { scan-assembler "#:got_lo12:" { target aarch64_small } } } */
+/* { dg-final { scan-assembler "blr" } } */
+/* { dg-final { scan-assembler-not "bl\t" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/noplt_2.c b/gcc/testsuite/gcc.target/aarch64/noplt_2.c
index 718999b..3be94aa 100644
--- a/gcc/testsuite/gcc.target/aarch64/noplt_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/noplt_2.c
@@ -14,5 +14,5 @@ foo (int a)
   return b0[a] + b1[a];
 }
 
-/* { dg-final { scan-assembler-times "#:got:" 1 { target { aarch64_tiny || aarch64_small } } } } */
-/* { dg-final { scan-assembler-times "#:got_lo12:" 1 { target aarch64_small } } } */
+/* { dg-final { scan-assembler-times "blr" 1 } } */
+/* { dg-final { scan-assembler-times "bl\t" 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/noplt_3.c b/gcc/testsuite/gcc.target/aarch64/noplt_3.c
index c1993b6..ef6e65d 100644
--- a/gcc/testsuite/gcc.target/aarch64/noplt_3.c
+++ b/gcc/testsuite/gcc.target/aarch64/noplt_3.c
@@ -16,5 +16,5 @@ cal_novalue (int a)
   dec (a);
 }
 
-/* { dg-final { scan-assembler-times "#:got:" 2 { target { aarch64_tiny || aarch64_small } } } } */
-/* { dg-final { scan-assembler-times "#:got_lo12:" 2 { target aarch64_small } } } */
+/* { dg-final { scan-assembler-times "br" 2 } } */
+/* { dg-final { scan-assembler-not "b\t" } } */

  reply	other threads:[~2015-08-07 13:28 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 16:38 PIC calls without PLT, generic implementation Alexander Monakov
2015-05-04 16:38 ` [PATCH i386] Allow sibcalls in no-PLT PIC Alexander Monakov
2015-05-15 16:37   ` Alexander Monakov
2015-05-15 16:48     ` H.J. Lu
2015-05-15 20:08       ` Jan Hubicka
2015-05-15 20:23         ` H.J. Lu
2015-05-15 20:35           ` Rich Felker
2015-05-15 20:37             ` H.J. Lu
2015-05-15 20:45               ` Rich Felker
2015-05-15 22:16                 ` H.J. Lu
2015-05-15 23:14                   ` Jan Hubicka
2015-05-15 23:30                     ` H.J. Lu
2015-05-15 23:35                       ` H.J. Lu
2015-05-15 23:44                         ` H.J. Lu
2015-05-16  0:18                           ` Rich Felker
2015-05-16 14:33                             ` H.J. Lu
2015-05-16 19:03                               ` H.J. Lu
2015-05-16 19:32                                 ` Rich Felker
2015-05-16 23:23                                   ` H.J. Lu
2015-05-15 23:49                       ` Rich Felker
2015-05-19 14:48                         ` Michael Matz
2015-05-19 15:11                           ` Jeff Law
2015-05-19 16:03                             ` Michael Matz
2015-05-19 19:11                               ` Rich Felker
2015-05-19 18:08                           ` Rich Felker
2015-05-19 19:03                             ` Richard Henderson
2015-05-19 19:10                               ` H.J. Lu
2015-05-19 19:17                                 ` Richard Henderson
2015-05-19 19:20                                   ` H.J. Lu
2015-05-19 19:54                                     ` Richard Henderson
2015-05-19 20:27                                     ` Rich Felker
2015-05-19 20:44                                       ` H.J. Lu
2015-05-19 21:28                                         ` Rich Felker
2015-05-20  0:52                                           ` H.J. Lu
2015-05-20  1:09                                             ` Rich Felker
2015-05-22 19:32                                               ` Richard Henderson
2015-05-19 19:48                               ` Rich Felker
2015-05-19 20:16                                 ` Richard Henderson
2015-05-20 12:13                               ` Michael Matz
2015-05-20 12:40                                 ` H.J. Lu
2015-05-20 14:17                                 ` Rich Felker
2015-05-20 14:33                                   ` Michael Matz
2015-05-18 18:25         ` Alexander Monakov
2015-05-18 19:03           ` Jan Hubicka
2015-05-04 16:38 ` [PATCH] Expand PIC calls without PLT with -fno-plt Alexander Monakov
2015-05-04 17:34   ` Jeff Law
2015-05-04 17:40     ` Jakub Jelinek
2015-05-04 17:42       ` Jeff Law
2015-05-06  3:08         ` Rich Felker
2015-05-10 17:07           ` Jan Hubicka
2015-05-06 15:25         ` Alexander Monakov
2015-05-06 15:46           ` Jakub Jelinek
2015-05-06 15:55             ` Jeff Law
2015-05-06 16:44             ` Alexander Monakov
2015-05-06 17:35               ` Rich Felker
2015-05-06 18:26                 ` H.J. Lu
2015-05-06 18:37                   ` Rich Felker
2015-05-06 18:45                     ` H.J. Lu
2015-05-06 19:01                       ` Rich Felker
2015-05-06 19:05                         ` H.J. Lu
2015-05-06 19:18                           ` Rich Felker
2015-05-06 19:24                             ` H.J. Lu
2015-05-11 11:48                             ` Michael Matz
2015-05-11 14:20                               ` Rich Felker
2015-05-07 18:22           ` Jeff Law
2015-05-07 19:13             ` H.J. Lu
2015-05-10 16:59   ` Jan Hubicka
2015-05-11 20:36     ` Jeff Law
2015-05-11 20:55       ` H.J. Lu
2015-05-11 22:13         ` Jan Hubicka
2015-06-22 15:52   ` Jiong Wang
2015-06-22 18:18     ` Alexander Monakov
2015-06-23  8:41       ` Ramana Radhakrishnan
2015-06-23 10:43         ` Alexander Monakov
2015-06-23 13:28         ` Jeff Law
2015-07-16 10:37           ` [AArch64] Tighten direct call pattern to repair -fno-plt Jiong Wang
2015-07-16 10:47             ` Alexander Monakov
2015-07-16 10:48               ` Jiong Wang
2015-07-21 12:52                 ` [AArch64][sibcall]Tighten " Jiong Wang
2015-08-04  9:50                   ` James Greenhalgh
2015-08-06 16:18                     ` [COMMITTED][AArch64][sibcall]Tighten " Jiong Wang
2015-08-07  8:22                       ` James Greenhalgh
2015-08-07 13:28                         ` Jiong Wang [this message]
2015-08-04  9:50             ` [AArch64] Tighten " James Greenhalgh
2015-08-06 16:16               ` [COMMITTED][AArch64] " Jiong Wang
2015-05-04 16:38 ` [PATCH i386] Extend sibcall peepholes to allow source in %eax Alexander Monakov
2015-05-10 16:54   ` Jan Hubicka
2015-05-11 17:50     ` Alexander Monakov
2015-05-11 18:00       ` Jan Hubicka
2015-05-11 19:46         ` Uros Bizjak
2015-05-11 19:48           ` Jeff Law
2015-05-11 20:16             ` Jan Hubicka
2015-05-13 19:05               ` Alexander Monakov
2015-05-13 20:04                 ` Jan Hubicka
2015-05-14 17:36                   ` Alexander Monakov
2015-05-04 16:38 ` [PATCH i386] Move CLOBBERED_REGS earlier in register class list Alexander Monakov
2015-05-10 16:44   ` Jan Hubicka
2015-05-10 17:51     ` Uros Bizjak
2015-05-10 18:09       ` Uros Bizjak
2015-05-11 16:26         ` Alexander Monakov
2015-05-11 16:30           ` Uros Bizjak
2015-05-04 16:38 ` [RFC PATCH] ira: accept loads via argp rtx in validate_equiv_mem Alexander Monakov
2015-05-04 17:37   ` Jeff Law
2015-05-04 16:38 ` [PATCH i386] PR65753: allow PIC tail calls via function pointers Alexander Monakov
2015-05-10 16:37   ` Jan Hubicka
2015-05-11 16:11     ` Alexander Monakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=n99egjfrzwa.fsf@arm.com \
    --to=jiong.wang@arm.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).