Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

190 lines
7.6KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Alias analysis (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Alias analysis (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Alias analysis (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Tree-SSA.html#Tree-SSA" rel="up" title="Tree SSA">
  30. <link href="Memory-model.html#Memory-model" rel="next" title="Memory model">
  31. <link href="SSA.html#SSA" rel="prev" title="SSA">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Alias-analysis"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Memory-model.html#Memory-model" accesskey="n" rel="next">Memory model</a>, Previous: <a href="SSA.html#SSA" accesskey="p" rel="prev">SSA</a>, Up: <a href="Tree-SSA.html#Tree-SSA" accesskey="u" rel="up">Tree SSA</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Alias-analysis-1"></a>
  68. <h3 class="section">13.4 Alias analysis</h3>
  69. <a name="index-alias"></a>
  70. <a name="index-flow_002dsensitive-alias-analysis"></a>
  71. <a name="index-flow_002dinsensitive-alias-analysis"></a>
  72. <p>Alias analysis in GIMPLE SSA form consists of two pieces. First
  73. the virtual SSA web ties conflicting memory accesses and provides
  74. a SSA use-def chain and SSA immediate-use chains for walking
  75. possibly dependent memory accesses. Second an alias-oracle can
  76. be queried to disambiguate explicit and implicit memory references.
  77. </p>
  78. <ol>
  79. <li> Memory SSA form.
  80. <p>All statements that may use memory have exactly one accompanied use of
  81. a virtual SSA name that represents the state of memory at the
  82. given point in the IL.
  83. </p>
  84. <p>All statements that may define memory have exactly one accompanied
  85. definition of a virtual SSA name using the previous state of memory
  86. and defining the new state of memory after the given point in the IL.
  87. </p>
  88. <div class="smallexample">
  89. <pre class="smallexample">int i;
  90. int foo (void)
  91. {
  92. # .MEM_3 = VDEF &lt;.MEM_2(D)&gt;
  93. i = 1;
  94. # VUSE &lt;.MEM_3&gt;
  95. return i;
  96. }
  97. </pre></div>
  98. <p>The virtual SSA names in this case are <code>.MEM_2(D)</code> and
  99. <code>.MEM_3</code>. The store to the global variable <code>i</code>
  100. defines <code>.MEM_3</code> invalidating <code>.MEM_2(D)</code>. The
  101. load from <code>i</code> uses that new state <code>.MEM_3</code>.
  102. </p>
  103. <p>The virtual SSA web serves as constraints to SSA optimizers
  104. preventing illegitimate code-motion and optimization. It
  105. also provides a way to walk related memory statements.
  106. </p>
  107. </li><li> Points-to and escape analysis.
  108. <p>Points-to analysis builds a set of constraints from the GIMPLE
  109. SSA IL representing all pointer operations and facts we do
  110. or do not know about pointers. Solving this set of constraints
  111. yields a conservatively correct solution for each pointer
  112. variable in the program (though we are only interested in
  113. SSA name pointers) as to what it may possibly point to.
  114. </p>
  115. <p>This points-to solution for a given SSA name pointer is stored
  116. in the <code>pt_solution</code> sub-structure of the
  117. <code>SSA_NAME_PTR_INFO</code> record. The following accessor
  118. functions are available:
  119. </p>
  120. <ul>
  121. <li> <code>pt_solution_includes</code>
  122. </li><li> <code>pt_solutions_intersect</code>
  123. </li></ul>
  124. <p>Points-to analysis also computes the solution for two special
  125. set of pointers, <code>ESCAPED</code> and <code>CALLUSED</code>. Those
  126. represent all memory that has escaped the scope of analysis
  127. or that is used by pure or nested const calls.
  128. </p>
  129. </li><li> Type-based alias analysis
  130. <p>Type-based alias analysis is frontend dependent though generic
  131. support is provided by the middle-end in <code>alias.c</code>. TBAA
  132. code is used by both tree optimizers and RTL optimizers.
  133. </p>
  134. <p>Every language that wishes to perform language-specific alias analysis
  135. should define a function that computes, given a <code>tree</code>
  136. node, an alias set for the node. Nodes in different alias sets are not
  137. allowed to alias. For an example, see the C front-end function
  138. <code>c_get_alias_set</code>.
  139. </p>
  140. </li><li> Tree alias-oracle
  141. <p>The tree alias-oracle provides means to disambiguate two memory
  142. references and memory references against statements. The following
  143. queries are available:
  144. </p>
  145. <ul>
  146. <li> <code>refs_may_alias_p</code>
  147. </li><li> <code>ref_maybe_used_by_stmt_p</code>
  148. </li><li> <code>stmt_may_clobber_ref_p</code>
  149. </li></ul>
  150. <p>In addition to those two kind of statement walkers are available
  151. walking statements related to a reference ref.
  152. <code>walk_non_aliased_vuses</code> walks over dominating memory defining
  153. statements and calls back if the statement does not clobber ref
  154. providing the non-aliased VUSE. The walk stops at
  155. the first clobbering statement or if asked to.
  156. <code>walk_aliased_vdefs</code> walks over dominating memory defining
  157. statements and calls back on each statement clobbering ref
  158. providing its aliasing VDEF. The walk stops if asked to.
  159. </p>
  160. </li></ol>
  161. <hr>
  162. <div class="header">
  163. <p>
  164. Next: <a href="Memory-model.html#Memory-model" accesskey="n" rel="next">Memory model</a>, Previous: <a href="SSA.html#SSA" accesskey="p" rel="prev">SSA</a>, Up: <a href="Tree-SSA.html#Tree-SSA" accesskey="u" rel="up">Tree SSA</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  165. </div>
  166. </body>
  167. </html>