]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | Liveness information | |
11 | ******************** | |
12 | ||
13 | Liveness information is useful to determine whether some register is | |
14 | 'live' at given point of program, i.e. that it contains a value that | |
15 | may be used at a later point in the program. This information is | |
16 | used, for instance, during register allocation, as the pseudo | |
17 | registers only need to be assigned to a unique hard register or to a | |
18 | stack slot if they are live. The hard registers and stack slots may | |
19 | be freely reused for other values when a register is dead. | |
20 | ||
21 | Liveness information is available in the back end starting with | |
22 | ``pass_df_initialize`` and ending with ``pass_df_finish``. Three | |
23 | flavors of live analysis are available: With ``LR``, it is possible | |
24 | to determine at any point ``P`` in the function if the register may be | |
25 | used 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 | |
27 | beginning of the function to ``P`` that defines the variable. | |
28 | ``LIVE`` is the intersection of the ``LR`` and ``UR`` and a | |
29 | variable is live at ``P`` if there is both an assignment that reaches | |
30 | it from the beginning of the function and a use that can be reached on | |
31 | some path from ``P`` to the end of the function. | |
32 | ||
33 | In 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. | |
35 | The macros take a basic block number and return a bitmap that is indexed | |
36 | by the register number. This information is only guaranteed to be up to | |
37 | date 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 | ||
42 | The liveness information is stored partly in the RTL instruction stream | |
43 | and partly in the flow graph. Local information is stored in the | |
44 | instruction stream: Each instruction may contain ``REG_DEAD`` notes | |
45 | representing that the value of a given register is no longer needed, or | |
46 | ``REG_UNUSED`` notes representing that the value computed by the | |
47 | instruction is never used. The second is useful for instructions | |
3ed1b4ce | 48 | computing multiple values at once. |