diff mbox

Committed, CRIS: fix target/71571, delay-slot nop in PIC MI thunk

Message ID 201606202009.u5KK9g22025424@ignucius.se.axis.com
State New
Headers show

Commit Message

Hans-Peter Nilsson June 20, 2016, 8:09 p.m. UTC
Committed to trunk.  Apparently the -fno-inline is key to
keeping the test-case small.
Thanks go to the reporter, David B. Robins.

gcc:
	PR target/71571
	* config/cris/cris.c (cris_asm_output_mi_thunk): Add missing "ba"
	delay-slot "nop" for PIC with CRIS v32.  Also add missing leading
	space for PIC with non-v32 and the common non-PIC "jump".

gcc/testsuite:
	PR target/71571
	* g++.dg/torture/pr71571.C: New test.


brgds, H-P
diff mbox

Patch

Index: gcc/config/cris/cris.c
===================================================================
--- gcc/config/cris/cris.c	(revision 235415)
+++ gcc/config/cris/cris.c	(working copy)
@@ -2772,18 +2772,18 @@  cris_asm_output_mi_thunk (FILE *stream,
 	{
 	  fprintf (stream, "\tba ");
 	  assemble_name (stream, name);
-	  fprintf (stream, "%s\n", CRIS_PLT_PCOFFSET_SUFFIX);
+	  fprintf (stream, "%s\n\tnop\n", CRIS_PLT_PCOFFSET_SUFFIX);
 	}
       else
 	{
-	  fprintf (stream, "add.d ");
+	  fprintf (stream, "\tadd.d ");
 	  assemble_name (stream, name);
 	  fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX);
 	}
     }
   else
     {
-      fprintf (stream, "jump ");
+      fprintf (stream, "\tjump ");
       assemble_name (stream, XSTR (XEXP (DECL_RTL (funcdecl), 0), 0));
       fprintf (stream, "\n");
 
--- /dev/null	Tue Oct 29 15:57:07 2002
+++ pr71571.C	Mon Jun 20 21:50:12 2016
@@ -0,0 +1,43 @@ 
+// { dg-do run }
+// { dg-options "-fno-inline" { target { ! fpic } } }
+// { dg-options "-fpic -fno-inline" { target fpic } }
+
+class XBase
+{
+public:
+ virtual void FuncA() = 0;
+};
+
+class Y
+{
+protected:
+ virtual void FuncB() {}
+};
+
+class X1 : public Y, public XBase
+{
+public:
+ void FuncA() {}
+};
+
+class X2 : public XBase
+{
+public:
+ X2(XBase &xb) : m_xb(xb) { }
+ void FuncA()
+ {
+  m_xb.FuncA();
+ }
+
+private:
+ XBase &m_xb;
+};
+
+
+int main()
+{
+ X1 x1;
+ X2 x2(x1);
+ XBase *pxb = &x2;
+ pxb->FuncA();
+}