Upwards exposed uses

From HandWiki
Revision as of 07:26, 31 July 2022 by imported>Wincert (simplify)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Upwards exposed uses or reachable uses,[1] is a concept in compiler theory which occurs in the copy propagation stage of compilation.[2]


During the copy propagation stage of program compilation, instances of a target are replaced with assignments to their values. During this process, it is necessary for the compiler to understand which instances of a target are being accessed so that appropriate substitution may occur, related to the concept of reaching definition in reaching analysis.[3] This is done with the purpose of simplifying code before execution: if the number of upwards exposed uses of an assignment is zero, it does not contribute to the end result of the code and can be safely removed.[1] This is also useful for improving code security during the compilation stages.[4]


Consider the following pseudocode:

x = 1
y = z

if False:
    x = 0
    x = y + 2

It is safe to assume that line 5 will never occur, as demonstrated by the number of upwards exposed uses for this point being zero. This can therefore be simplified:

y = z
x = z + 2

This leads to an end result which is less complex to compile, and more efficient to run.[2] This also meets the definition of reaching definition: In this context, upwards flow analysis was the technique used to demonstrate the needs for reaching definition. Additional techniques allow for more complex analysis of more deeply intertwined or complex control flow problems, such as those with various forms of loops.[4]

See also


  1. 1.0 1.1 Harrold, Mary Jean (Fall 2009). "Basic Analysis". Georgia Tech - College of Computing. Atlanta, Georgia, USA: Georgia Institute of Technology. https://www.cc.gatech.edu/~harrold/6340/cs6340_fall2009/Slides/BasicAnalysis3.pdf. 
  2. 2.0 2.1 Aho, Alfred Vaino; Lam, Monica Sin-Ling; Sethi, Ravi; Ullman, Jeffrey David (2006). Compilers: Principles, Techniques, and Tools (2 ed.). Boston, Massachusetts, USA: Addison-Wesley. ISBN 0-321-48681-1. OCLC 70775643. 
  3. Kore, Aamod (2020). "Upwards Exposed Uses". Toronto, Ontario, Canada: Department of Computer Science, University of Toronto. https://www.cs.toronto.edu/~aamodkore/notes/dfa-tutorial/hw3-exposed-uses.html. 
  4. 4.0 4.1 Bergeretti, Jean-Francois; Carré, Bernard A. (1985-01-02). "Information-Flow and Data-Flow Analysis of while-Programs". ACM Transactions on Programming Languages and Systems (Association for Computing Machinery) 7 (1): 37–61. doi:10.1145/2363.2366. https://dl.acm.org/doi/pdf/10.1145/2363.2366. Retrieved 2020-06-20.