microMIPS/GCC: Fix PIC call relaxation

gcc/
	* config/mips/mips.c (mips_output_jump): Output R_MICROMIPS_JALR
	rather than R_MIPS_JALR relocation in microMIPS code.  Do not
	cancel short delay slots in PIC call relaxation.

	gcc/testsuite/
	* gcc.target/mips/call-1.c (dg-options): Add `-mno-micromips'.
	(dg-final): Remove microMIPS JALRS mnemonic matching.
	* gcc.target/mips/call-2.c (dg-options): Add `-mno-micromips'.
	(dg-final): Remove microMIPS JALRS mnemonic matching.
	* gcc.target/mips/call-3.c (dg-options): Add `-mno-micromips'.
	(dg-final): Remove microMIPS JALRS mnemonic matching.
	* gcc.target/mips/call-4.c (dg-options): Add `-mno-micromips'.
	* gcc.target/mips/call-5.c (dg-options): Add `-mno-micromips'.
	* gcc.target/mips/call-6.c (dg-options): Add `-mno-micromips'.
	* gcc.target/mips/call-1u.c: New test case.
	* gcc.target/mips/call-2u.c: New test case.
	* gcc.target/mips/call-3u.c: New test case.
	* gcc.target/mips/call-4u.c: New test case.
	* gcc.target/mips/call-5u.c: New test case.
	* gcc.target/mips/call-6u.c: New test case.

From-SVN: r242512
This commit is contained in:
Maciej W. Rozycki 2016-11-16 21:05:01 +00:00 committed by Maciej W. Rozycki
parent 3549e181bd
commit 8e2be5aefc
15 changed files with 231 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2016-11-16 Maciej W. Rozycki <macro@imgtec.com>
* config/mips/mips.c (mips_output_jump): Output R_MICROMIPS_JALR
rather than R_MIPS_JALR relocation in microMIPS code. Do not
cancel short delay slots in PIC call relaxation.
2016-11-16 Thomas Preud'homme <thomas.preudhomme@arm.com>
* config/arm/arm.md (arm_addsi3): Add alternative for addition of

View File

@ -13618,12 +13618,9 @@ mips_output_jump (rtx *operands, int target_opno, int size_opno, bool link_p)
s += sprintf (s, ".option\tpic0\n\t");
if (reg_p && mips_get_pic_call_symbol (operands, size_opno))
{
s += sprintf (s, "%%*.reloc\t1f,R_MIPS_JALR,%%%d\n1:\t", size_opno);
/* Not sure why this shouldn't permit a short delay but it did not
allow it before so we still don't allow it. */
short_delay = "";
}
s += sprintf (s, "%%*.reloc\t1f,%s,%%%d\n1:\t",
TARGET_MICROMIPS ? "R_MICROMIPS_JALR" : "R_MIPS_JALR",
size_opno);
else
s += sprintf (s, "%%*");

View File

@ -1,3 +1,21 @@
2016-11-16 Maciej W. Rozycki <macro@imgtec.com>
* gcc.target/mips/call-1.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-2.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-3.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-4.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-5.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-6.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-1u.c: New test case.
* gcc.target/mips/call-2u.c: New test case.
* gcc.target/mips/call-3u.c: New test case.
* gcc.target/mips/call-4u.c: New test case.
* gcc.target/mips/call-5u.c: New test case.
* gcc.target/mips/call-6u.c: New test case.
2016-11-16 Thomas Preud'homme <thomas.preudhomme@arm.com>
* gcc.target/arm/empty_fiq_handler.c: New test.

View File

@ -1,8 +1,8 @@
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=32" } */
/* { dg-options "-mno-micromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalrc?s?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalrc?s?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalrc?s?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail2\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail3\n1:\tjrc?\t" } } */

View File

@ -0,0 +1,51 @@
/* { dg-options "-mmicromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal2\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,staticfunc\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail2\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail3\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail4\n1:\tjrc?\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal ();
void normal2 ();
int
NOMIPS16 f (int *p)
{
*p = normal ();
normal2 ();
staticfunc ();
return 1;
}
int tail ();
int
NOMIPS16 h ()
{
return tail ();
}
void tail2 ();
NOMIPS16 void g ()
{
tail2 ();
}
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}

View File

@ -1,6 +1,6 @@
/* See through some simple data-flow. */
/* { dg-options "-mrelax-pic-calls" } */
/* { dg-final { scan-assembler-times "\\.reloc\t1f,R_MIPS_JALR,g\n1:\tjalrc?s?\t" 2 } } */
/* { dg-options "-mno-micromips -mrelax-pic-calls" } */
/* { dg-final { scan-assembler-times "\\.reloc\t1f,R_MIPS_JALR,g\n1:\tjalrc?\t" 2 } } */
extern void g (void);

View File

@ -0,0 +1,13 @@
/* See through some simple data-flow. */
/* { dg-options "-mmicromips -mrelax-pic-calls" } */
/* { dg-final { scan-assembler-times "\\.reloc\t1f,R_MICROMIPS_JALR,g\n1:\tjalrs?\t" 2 } } */
extern void g (void);
int
NOMIPS16 f ()
{
g ();
g ();
return 1;
}

View File

@ -1,5 +1,5 @@
/* { dg-options "-mrelax-pic-calls -mno-shared" } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,g\n1:\tjalrc?s?\t" } } */
/* { dg-options "-mno-micromips -mrelax-pic-calls -mno-shared" } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,g\n1:\tjalrc?\t" } } */
/* { dg-require-visibility "" } */
__attribute__ ((visibility ("hidden"))) void g ();

View File

@ -0,0 +1,12 @@
/* { dg-options "-mmicromips -mrelax-pic-calls -mno-shared" } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,g\n1:\tjalrs?\t" } } */
/* { dg-require-visibility "" } */
__attribute__ ((visibility ("hidden"))) void g ();
int
NOMIPS16 f ()
{
g ();
return 1;
}

View File

@ -1,5 +1,5 @@
/* See through some simple data-flow. */
/* { dg-options "-mrelax-pic-calls" } */
/* { dg-options "-mno-micromips -mrelax-pic-calls" } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,g\n1:\tjalrc?\t" } } */
extern void g (void);

View File

@ -0,0 +1,12 @@
/* See through some simple data-flow. */
/* { dg-options "-mmicromips -mrelax-pic-calls" } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,g\n1:\tjalrs?\t" } } */
extern void g (void);
int
NOMIPS16 f (int i)
{
while (i--)
g ();
}

View File

@ -1,6 +1,6 @@
/* Like call-1.c, but for n32. We cannot use sibling calls for tail and tail2
in this case (PR target/57260). */
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=n32" } */
/* { dg-options "-mno-micromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=n32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalrc?\t" } } */

View File

@ -0,0 +1,53 @@
/* Like call-1.c, but for n32. We cannot use sibling calls for tail and tail2
in this case (PR target/57260). */
/* { dg-options "-mmicromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=n32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal2\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,staticfunc\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail2\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail3\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail4\n1:\tjrc?\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal ();
void normal2 ();
int
NOMIPS16 f (int *p)
{
*p = normal ();
normal2 ();
staticfunc ();
return 1;
}
int tail ();
int
NOMIPS16 h ()
{
return tail ();
}
void tail2 ();
NOMIPS16 void g ()
{
tail2 ();
}
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}

View File

@ -1,5 +1,5 @@
/* Like call-5.c, but for n64. */
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=64" } */
/* { dg-options "-mno-micromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=64" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalrc?\t" } } */

View File

@ -0,0 +1,52 @@
/* Like call-5.c, but for n64. */
/* { dg-options "-mmicromips -mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=64" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,normal2\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,staticfunc\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail2\n1:\tjalrs?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail3\n1:\tjrc?\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MICROMIPS_JALR,tail4\n1:\tjrc?\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal ();
void normal2 ();
int
NOMIPS16 f (int *p)
{
*p = normal ();
normal2 ();
staticfunc ();
return 1;
}
int tail ();
int
NOMIPS16 h ()
{
return tail ();
}
void tail2 ();
NOMIPS16 void g ()
{
tail2 ();
}
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}