ipa-ref.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Interprocedural reference lists.
  2. Copyright (C) 2010-2015 Free Software Foundation, Inc.
  3. Contributed by Jan Hubicka
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #include "config.h"
  17. #include "system.h"
  18. #include "coretypes.h"
  19. #include "hash-set.h"
  20. #include "machmode.h"
  21. #include "vec.h"
  22. #include "double-int.h"
  23. #include "input.h"
  24. #include "alias.h"
  25. #include "symtab.h"
  26. #include "options.h"
  27. #include "wide-int.h"
  28. #include "inchash.h"
  29. #include "tree.h"
  30. #include "fold-const.h"
  31. #include "ggc.h"
  32. #include "target.h"
  33. #include "hash-map.h"
  34. #include "is-a.h"
  35. #include "plugin-api.h"
  36. #include "tm.h"
  37. #include "hard-reg-set.h"
  38. #include "input.h"
  39. #include "function.h"
  40. #include "ipa-ref.h"
  41. #include "cgraph.h"
  42. #include "ipa-utils.h"
  43. /* Remove reference. */
  44. void
  45. ipa_ref::remove_reference ()
  46. {
  47. struct ipa_ref_list *list = referred_ref_list ();
  48. struct ipa_ref_list *list2 = referring_ref_list ();
  49. vec<ipa_ref_t, va_gc> *old_references = list2->references;
  50. struct ipa_ref *last;
  51. gcc_assert (list->referring[referred_index] == this);
  52. last = list->referring.last ();
  53. if (this != last)
  54. {
  55. if (use == IPA_REF_ALIAS)
  56. {
  57. /* If deleted item is IPA_REF_ALIAS, we have to move last
  58. item of IPA_REF_LIST type to the deleted position. After that
  59. we replace last node with deletion slot. */
  60. struct ipa_ref *last_alias = list->last_alias ();
  61. if (last_alias && referred_index < last_alias->referred_index
  62. && last_alias != last)
  63. {
  64. unsigned last_alias_index = last_alias->referred_index;
  65. list->referring[referred_index] = last_alias;
  66. list->referring[referred_index]->referred_index = referred_index;
  67. /* New position for replacement is previous index
  68. of the last_alias. */
  69. referred_index = last_alias_index;
  70. }
  71. }
  72. list->referring[referred_index] = list->referring.last ();
  73. list->referring[referred_index]->referred_index= referred_index;
  74. }
  75. list->referring.pop ();
  76. last = &list2->references->last ();
  77. struct ipa_ref *ref = this;
  78. if (ref != last)
  79. {
  80. *ref = *last;
  81. ref->referred_ref_list ()->referring[referred_index] = ref;
  82. }
  83. list2->references->pop ();
  84. gcc_assert (list2->references == old_references);
  85. }
  86. /* Return true when execution of reference can lead to return from
  87. function. */
  88. bool
  89. ipa_ref::cannot_lead_to_return ()
  90. {
  91. return dyn_cast <cgraph_node *> (referring)->cannot_return_p ();
  92. }
  93. /* Return reference list this reference is in. */
  94. struct ipa_ref_list *
  95. ipa_ref::referring_ref_list (void)
  96. {
  97. return &referring->ref_list;
  98. }
  99. /* Return reference list this reference is in. */
  100. struct ipa_ref_list *
  101. ipa_ref::referred_ref_list (void)
  102. {
  103. return &referred->ref_list;
  104. }