Jiong Wang writes:

> Alexander Monakov writes:
>
>>> Attachment is the patch which repair -fno-plt support for AArch64.
>>> 
>>> aarch64_is_noplt_call_p will only be true if:
>>> 
>>>   * gcc is generating position independent code.
>>>   * function symbol has declaration.
>>>   * either -fno-plt or "(no_plt)" attribute specified.
>>>   * it's a external function.
>>>   
>>> OK for trunk?
>>> 
>>> 2015-07-16  Jiong Wang  <jiong.w...@arm.com>
>>> 
>>> gcc/
>>>   * config/aarch64/aarch64-protos.h (aarch64_is_noplt_call_p): New
>>>   declaration.
>>>   * config/aarch64/aarch64.c (aarch64_is_noplt_call_p): New function.
>>>   * config/aarch64/aarch64.md (call_value_symbol): Check noplt
>>>   scenarios.
>>>   (call_symbol): Ditto.
>>
>> Shouldn't the same treatment be applied to tailcall (sibcall_{,value_}symbol)
>> patterns?  I guess it could be done as a followup patch, but would be nice if
>> that isn't forgotten.
>
> Thanks for the remaind, that will be done as a followup patch.

Patch attached.

Added one more restriction to "Usf" constraint which is used by sibcall
pattern when matching direct call.

given example like

void
cal_novalue (int a)
{
  dec (a);
}

when -fpic -fno-plt specified we now generate:

cal:
        adrp    x1, :got:dec
        ldr     x1, [x1, #:got_lo12:dec]
        br      x1

instead of:

cal:
        b dec

2015-07-20  Jiong Wang  <jiong.w...@arm.com>

gcc/
  * config/aarch64/constraints.md (Usf): Add the test of
  aarch64_is_noplt_call_p.

gcc/testsuite/
  * gcc.target/aarch64/noplt_3.c: New test.

-- 
Regards,
Jiong

diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md
index 5b189ea..9dc2108 100644
--- a/gcc/config/aarch64/constraints.md
+++ b/gcc/config/aarch64/constraints.md
@@ -101,8 +101,9 @@
        (match_test "(unsigned HOST_WIDE_INT) ival < 64")))
 
 (define_constraint "Usf"
-  "@internal Usf is a symbol reference."
-  (match_code "symbol_ref"))
+  "@internal Usf is a symbol reference under the context where plt stub allowed."
+  (and (match_code "symbol_ref")
+       (match_test "!aarch64_is_noplt_call_p (op)")))
 
 (define_constraint "UsM"
   "@internal
diff --git a/gcc/testsuite/gcc.target/aarch64/noplt_3.c b/gcc/testsuite/gcc.target/aarch64/noplt_3.c
new file mode 100644
index 0000000..54b51bd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/noplt_3.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpic -fno-plt" } */
+/* { dg-skip-if "-mcmodel=large, no support for -fpic" { aarch64-*-* }  { "-mcmodel=large" } { "" } } */
+
+int dec (int);
+
+int
+cal (int a)
+{
+  return dec (a);
+}
+
+void
+cal_novalue (int a)
+{
+  dec (a);
+}
+
+/* { dg-final { scan-assembler-times "#:got:" 2 } } */

Reply via email to