1

I want to do backward dataflow analysis using LLVM. Currently, I just create a new Pass class:

class BwdfPass: public llvm::ModulePass{}

Then, implement the runOnModule method and runOnFunction method. However, I just saw some examples like:

void BwdfPass::runOnFunction(Function &function){
    for(BasicBlock & bb: function){
        for(Instruction &inst:bb){
            //do some action
        }
    }
}

I once did dataflow analysis with soot. Soot provide an interface BackwardFlowAnalysis, and I only need to implement the transfer function in the method doAnalysis(). The worklist algorithm which achieve fix-point analysis is provided by its interface. However, in LLVM, is there any similar mechanism? Does it mean I need to implement the worklist algorithm and go through all the Instructions in a backward order by by myself?

Ya Xiao
  • 861
  • 8
  • 16
  • I noticed there is a library llvm.Analysis.Dataflow which does such thing. However, it is a Haskell library. Honestly, this is my first time to heard such a language? Is there any similar thing in C++? – Ya Xiao Jun 10 '19 at 09:25

1 Answers1

0

I encourage you to have a look at our LLVM extension Phasar: https://phasar.org/

It provides functionality similar to Soot does for Java.

Eric
  • 1,343
  • 1
  • 11
  • 19