BinaryAnalysisPlatform / bap

Binary Analysis Platform
MIT License
2.05k stars 271 forks source link

updates the `Sub.compute_liveness` function to handle SSA form #1445

Closed ivg closed 2 years ago

ivg commented 2 years ago

The Sub.compute_liveness function was accidentally published in #1051 without consideration that it works only for the non-SSA form. This PR fixes this by updating the algorithm to handle the SSA form as well.

The semantics of phi nodes modulo liveness is the following. For a phi-node at block b0, x0 := phi([b1,x1; b2,x2;...;bN,xN]), the defined variable x0 is considered to be at the entry of b0, i.e., x0 is live-in of b0, and the variable xi is live-out of basic block bi, for i > 0.

Informally, a phi-node defines the values on the corresponding edges of the predecessors.