toolchain/gcc-linaro-6.3.1-2017.02-x8.../share/doc/gccint/Liveness-information.html

129 lines
6.2 KiB
HTML
Raw Normal View History

2024-03-22 05:10:17 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2016 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
"GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development. -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Compiler Collection (GCC) Internals: Liveness information</title>
<meta name="description" content="GNU Compiler Collection (GCC) Internals: Liveness information">
<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Liveness information">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Control-Flow.html#Control-Flow" rel="up" title="Control Flow">
<link href="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" rel="next" title="Loop Analysis and Representation">
<link href="Maintaining-the-CFG.html#Maintaining-the-CFG" rel="prev" title="Maintaining the CFG">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Liveness-information"></a>
<div class="header">
<p>
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>
</div>
<hr>
<a name="Liveness-information-1"></a>
<h3 class="section">14.5 Liveness information</h3>
<a name="index-Liveness-representation"></a>
<p>Liveness information is useful to determine whether some register is
&ldquo;live&rdquo; at given point of program, i.e. that it contains a value that
may be used at a later point in the program. This information is
used, for instance, during register allocation, as the pseudo
registers only need to be assigned to a unique hard register or to a
stack slot if they are live. The hard registers and stack slots may
be freely reused for other values when a register is dead.
</p>
<p>Liveness information is available in the back end starting with
<code>pass_df_initialize</code> and ending with <code>pass_df_finish</code>. Three
flavors of live analysis are available: With <code>LR</code>, it is possible
to determine at any point <code>P</code> in the function if the register may be
used on some path from <code>P</code> to the end of the function. With
<code>UR</code>, it is possible to determine if there is a path from the
beginning of the function to <code>P</code> that defines the variable.
<code>LIVE</code> is the intersection of the <code>LR</code> and <code>UR</code> and a
variable is live at <code>P</code> if there is both an assignment that reaches
it from the beginning of the function and a use that can be reached on
some path from <code>P</code> to the end of the function.
</p>
<p>In general <code>LIVE</code> is the most useful of the three. The macros
<code>DF_[LR,UR,LIVE]_[IN,OUT]</code> can be used to access this information.
The macros take a basic block number and return a bitmap that is indexed
by the register number. This information is only guaranteed to be up to
date after calls are made to <code>df_analyze</code>. See the file
<code>df-core.c</code> for details on using the dataflow.
</p>
<a name="index-REG_005fDEAD_002c-REG_005fUNUSED"></a>
<p>The liveness information is stored partly in the RTL instruction stream
and partly in the flow graph. Local information is stored in the
instruction stream: Each instruction may contain <code>REG_DEAD</code> notes
representing that the value of a given register is no longer needed, or
<code>REG_UNUSED</code> notes representing that the value computed by the
instruction is never used. The second is useful for instructions
computing multiple values at once.
</p>
<hr>
<div class="header">
<p>
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>
</div>
</body>
</html>