901-UPDATE1-Fix-handling-complex-PIC-moves.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From f00b0f17d6889d811468c2c77508fbea8bfc377d Mon Sep 17 00:00:00 2001
  2. From: Claudiu Zissulescu <claziss@synopsys.com>
  3. Date: Tue, 19 Jan 2016 14:40:16 +0100
  4. Subject: [PATCH] UPDATE1: Fix handling complex PIC moves.
  5. The arc_legitimate_pc_offset_p condition is too lax. Updated it.
  6. The fix is done in development tree: [arc-4.8-dev f00b0f1]
  7. and will be a part of the next release of ARC GNU tools.
  8. Once that new release happens this patch must be removed.
  9. gcc/
  10. 2016-01-18 Claudiu Zissulescu <claziss@synopsys.com>
  11. * config/arc/arc.c (arc_needs_pcl_p ): New function
  12. (arc_legitimate_pc_offset_p): Use arc_needs_pcl_p.
  13. ---
  14. gcc/config/arc/arc.c | 42 ++++++++++++++++++++++++++++++++++++++++--
  15. 1 file changed, 40 insertions(+), 2 deletions(-)
  16. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
  17. index f7cae9f..18d88a3 100644
  18. --- a/gcc/config/arc/arc.c
  19. +++ b/gcc/config/arc/arc.c
  20. @@ -5234,6 +5234,45 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED,
  21. }
  22. }
  23. +/* Helper used by arc_legitimate_pc_offset_p. */
  24. +
  25. +static bool
  26. +arc_needs_pcl_p (rtx x)
  27. +{
  28. + register const char *fmt;
  29. + register int i, j;
  30. +
  31. + if ((GET_CODE (x) == UNSPEC)
  32. + && (XVECLEN (x, 0) == 1)
  33. + && (GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF))
  34. + switch (XINT (x, 1))
  35. + {
  36. + case ARC_UNSPEC_GOT:
  37. + case ARC_UNSPEC_GOTOFFPC:
  38. + case UNSPEC_TLS_GD:
  39. + case UNSPEC_TLS_IE:
  40. + return true;
  41. + default:
  42. + break;
  43. + }
  44. +
  45. + fmt = GET_RTX_FORMAT (GET_CODE (x));
  46. + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
  47. + {
  48. + if (fmt[i] == 'e')
  49. + {
  50. + if (arc_needs_pcl_p (XEXP (x, i)))
  51. + return true;
  52. + }
  53. + else if (fmt[i] == 'E')
  54. + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  55. + if (arc_needs_pcl_p (XVECEXP (x, i, j)))
  56. + return true;
  57. + }
  58. +
  59. + return false;
  60. +}
  61. +
  62. /* Return true if ADDR is an address that needs to be expressed as an
  63. explicit sum of pcl + offset. */
  64. @@ -5242,8 +5281,7 @@ arc_legitimate_pc_offset_p (rtx addr)
  65. {
  66. if (GET_CODE (addr) != CONST)
  67. return false;
  68. - addr = XEXP (addr, 0);
  69. - return flag_pic && !arc_raw_symbolic_reference_mentioned_p (addr, false);
  70. + return arc_needs_pcl_p (addr);
  71. }
  72. /* Return true if ADDR is a valid pic address.
  73. --
  74. 2.5.0