Liveness-information.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Liveness information</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Liveness information">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Liveness information">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Control-Flow.html#Control-Flow" rel="up" title="Control Flow">
  30. <link href="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" rel="next" title="Loop Analysis and Representation">
  31. <link href="Maintaining-the-CFG.html#Maintaining-the-CFG" rel="prev" title="Maintaining the CFG">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Liveness-information"></a>
  63. <div class="header">
  64. <p>
  65. Previous: <a href="Maintaining-the-CFG.html#Maintaining-the-CFG" accesskey="p" rel="prev">Maintaining the CFG</a>, Up: <a href="Control-Flow.html#Control-Flow" accesskey="u" rel="up">Control Flow</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>
  66. </div>
  67. <hr>
  68. <a name="Liveness-information-1"></a>
  69. <h3 class="section">14.5 Liveness information</h3>
  70. <a name="index-Liveness-representation"></a>
  71. <p>Liveness information is useful to determine whether some register is
  72. &ldquo;live&rdquo; at given point of program, i.e. that it contains a value that
  73. may be used at a later point in the program. This information is
  74. used, for instance, during register allocation, as the pseudo
  75. registers only need to be assigned to a unique hard register or to a
  76. stack slot if they are live. The hard registers and stack slots may
  77. be freely reused for other values when a register is dead.
  78. </p>
  79. <p>Liveness information is available in the back end starting with
  80. <code>pass_df_initialize</code> and ending with <code>pass_df_finish</code>. Three
  81. flavors of live analysis are available: With <code>LR</code>, it is possible
  82. to determine at any point <code>P</code> in the function if the register may be
  83. used on some path from <code>P</code> to the end of the function. With
  84. <code>UR</code>, it is possible to determine if there is a path from the
  85. beginning of the function to <code>P</code> that defines the variable.
  86. <code>LIVE</code> is the intersection of the <code>LR</code> and <code>UR</code> and a
  87. variable is live at <code>P</code> if there is both an assignment that reaches
  88. it from the beginning of the function and a use that can be reached on
  89. some path from <code>P</code> to the end of the function.
  90. </p>
  91. <p>In general <code>LIVE</code> is the most useful of the three. The macros
  92. <code>DF_[LR,UR,LIVE]_[IN,OUT]</code> can be used to access this information.
  93. The macros take a basic block number and return a bitmap that is indexed
  94. by the register number. This information is only guaranteed to be up to
  95. date after calls are made to <code>df_analyze</code>. See the file
  96. <code>df-core.c</code> for details on using the dataflow.
  97. </p>
  98. <a name="index-REG_005fDEAD_002c-REG_005fUNUSED"></a>
  99. <p>The liveness information is stored partly in the RTL instruction stream
  100. and partly in the flow graph. Local information is stored in the
  101. instruction stream: Each instruction may contain <code>REG_DEAD</code> notes
  102. representing that the value of a given register is no longer needed, or
  103. <code>REG_UNUSED</code> notes representing that the value computed by the
  104. instruction is never used. The second is useful for instructions
  105. computing multiple values at once.
  106. </p>
  107. <hr>
  108. <div class="header">
  109. <p>
  110. Previous: <a href="Maintaining-the-CFG.html#Maintaining-the-CFG" accesskey="p" rel="prev">Maintaining the CFG</a>, Up: <a href="Control-Flow.html#Control-Flow" accesskey="u" rel="up">Control Flow</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>
  111. </div>
  112. </body>
  113. </html>