]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorMihail Ionescu <mihail.ionescu@arm.com>
Wed, 21 Nov 2018 16:50:37 +0000 (16:50 +0000)
committerThomas Preud'homme <thopre01@gcc.gnu.org>
Wed, 21 Nov 2018 16:50:37 +0000 (16:50 +0000)
2018-11-21  Mihail Ionescu  <mihail.ionescu@arm.com>

gcc/
PR target/87867
Backport from mainiline
2018-09-26  Eric Botcazou  <ebotcazou@adacore.com>

* config/arm/arm.c (arm_reorg): Skip Thumb reorg pass for thunks.
(arm32_output_mi_thunk): Deal with long calls.

gcc/testsuite/
PR target/87867
Backport from mainiline
2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>

* g++.dg/other/thunk2a.C: New test.
* g++.dg/other/thunk2b.C: Likewise.

From-SVN: r266348

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/thunk1.C [moved from gcc/testsuite/g++.dg/other/vthunk1.C with 100% similarity]
gcc/testsuite/g++.dg/other/thunk2a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/thunk2b.C [new file with mode: 0644]

index ac62043af560d833d38bbd6ad0846bd2b43832aa..67e86809b4d24b86ed5ebb859cf4fa421feab11b 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-21  Mihail Ionescu  <mihail.ionescu@arm.com>
+
+       PR target/87867
+       Backport from mainiline
+       2018-09-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * config/arm/arm.c (arm_reorg): Skip Thumb reorg pass for thunks.
+       (arm32_output_mi_thunk): Deal with long calls.
+
 2018-11-20  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index f0058a2722d2b3f50a789c3693b28e0e90b430c4..dd1f91f5efa1c85a908d50caa73173419c832000 100644 (file)
@@ -17367,7 +17367,11 @@ arm_reorg (void)
 
   if (use_cmse)
     cmse_nonsecure_call_clear_caller_saved ();
-  if (TARGET_THUMB1)
+
+  /* We cannot run the Thumb passes for thunks because there is no CFG.  */
+  if (cfun->is_thunk)
+    ;
+  else if (TARGET_THUMB1)
     thumb1_reorg ();
   else if (TARGET_THUMB2)
     thumb2_reorg ();
@@ -26429,6 +26433,8 @@ static void
 arm32_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT delta,
                       HOST_WIDE_INT vcall_offset, tree function)
 {
+  const bool long_call_p = arm_is_long_call_p (function);
+
   /* On ARM, this_regno is R0 or R1 depending on
      whether the function returns an aggregate or not.
   */
@@ -26466,9 +26472,22 @@ arm32_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT delta,
       TREE_USED (function) = 1;
     }
   rtx funexp = XEXP (DECL_RTL (function), 0);
+  if (long_call_p)
+    {
+      emit_move_insn (temp, funexp);
+      funexp = temp;
+    }
   funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
-  rtx_insn * insn = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
+  rtx_insn *insn = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
   SIBLING_CALL_P (insn) = 1;
+  emit_barrier ();
+
+  /* Indirect calls require a bit of fixup in PIC mode.  */
+  if (long_call_p)
+    {
+      split_all_insns_noflow ();
+      arm_reorg ();
+    }
 
   insn = get_insns ();
   shorten_branches (insn);
index 244e42dfd54c68dda6b0d0566334318966f7ed56..58e8566b9e8757182c5c9d21eba083860c2a3a18 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-21  Mihail Ionescu  <mihail.ionescu@arm.com>
+
+       PR target/87867
+       Backport from mainiline
+       2018-09-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * g++.dg/other/thunk2a.C: New test.
+       * g++.dg/other/thunk2b.C: Likewise.
+
 2018-11-20  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/other/thunk2a.C b/gcc/testsuite/g++.dg/other/thunk2a.C
new file mode 100644 (file)
index 0000000..8e5ebd4
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile { target arm*-*-* } }
+// { dg-options "-mlong-calls -ffunction-sections" }
+
+class a {
+public:
+  virtual ~a();
+};
+
+class b : virtual a {};
+
+class c : b {
+  ~c();
+};
+
+c::~c() {}
diff --git a/gcc/testsuite/g++.dg/other/thunk2b.C b/gcc/testsuite/g++.dg/other/thunk2b.C
new file mode 100644 (file)
index 0000000..c8f4570
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do compile { target arm*-*-* } }
+// { dg-options "-mlong-calls -ffunction-sections" }
+// { dg-additional-options "-fPIC" { target fpic } }
+
+class a {
+public:
+  virtual ~a();
+};
+
+class b : virtual a {};
+
+class c : b {
+  ~c();
+};
+
+c::~c() {}