]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gccint/control-flow-graph/liveness-information.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / control-flow-graph / liveness-information.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: Liveness representation
7
8.. _liveness-information:
9
10Liveness information
11********************
12
13Liveness information is useful to determine whether some register is
14'live' at given point of program, i.e. that it contains a value that
15may be used at a later point in the program. This information is
16used, for instance, during register allocation, as the pseudo
17registers only need to be assigned to a unique hard register or to a
18stack slot if they are live. The hard registers and stack slots may
19be freely reused for other values when a register is dead.
20
21Liveness information is available in the back end starting with
22``pass_df_initialize`` and ending with ``pass_df_finish``. Three
23flavors of live analysis are available: With ``LR``, it is possible
24to determine at any point ``P`` in the function if the register may be
25used on some path from ``P`` to the end of the function. With
26``UR``, it is possible to determine if there is a path from the
27beginning of the function to ``P`` that defines the variable.
28``LIVE`` is the intersection of the ``LR`` and ``UR`` and a
29variable is live at ``P`` if there is both an assignment that reaches
30it from the beginning of the function and a use that can be reached on
31some path from ``P`` to the end of the function.
32
33In general ``LIVE`` is the most useful of the three. The macros
34``DF_[LR,UR,LIVE]_[IN,OUT]`` can be used to access this information.
35The macros take a basic block number and return a bitmap that is indexed
36by the register number. This information is only guaranteed to be up to
37date after calls are made to ``df_analyze``. See the file
38``df-core.cc`` for details on using the dataflow.
39
40.. index:: REG_DEAD, REG_UNUSED
41
42The liveness information is stored partly in the RTL instruction stream
43and partly in the flow graph. Local information is stored in the
44instruction stream: Each instruction may contain ``REG_DEAD`` notes
45representing that the value of a given register is no longer needed, or
46``REG_UNUSED`` notes representing that the value computed by the
47instruction is never used. The second is useful for instructions
3ed1b4ce 48computing multiple values at once.