Live variable analysis

Hi, I'm writing an LLVM pass for my research. As the part of that pass I need to find all live variables at the entry point of basic block and replace all usages of that variables, which are "lower" than that block (usages in successors of the block, in successors of successors and so on). Is there any suitable analysis for finding live variables at the entry point of the block and for determining if basic block is situated "lower" than some other block?

Natasha Kharchenko

There is a liveness analysis inside Utils/PromoteMemoryToRegister.cpp. Take a look into the ComputeLiveInBlocks function.

I just used the same algorithm in my project as well.