pingpongpu
pingpongpu

Reputation: 11

Creating an LLVM Analysis Pass

I want to create an analysis pass that can be used in the same way as the 'premade' analysis passes that LLVM comes with, i.e. with getAnalysisUsage etc.

I've really struggled to find documentation on how to do this, or do something equivalent.

I'm sure this is a fairly involved process, but even a link to the correct procedure would be invaluable. I'm sure I'm not the only one who has hit this issue, so this would be helpful to others as well.

Upvotes: 1

Views: 1663

Answers (1)

serge-sans-paille
serge-sans-paille

Reputation: 2139

An analysis is just a pass that does not modify the bytecode and stores an internal state that can be later retrieved.

So all you need to do is write an LLVM pass, register it as an analysis (third and fourth parameters of RegisterPass set to true), and provide a public method to access the internal state.

Attached to the tutorial presented at the october 2015 LLVM Developper meeting, there's a git repo. You'll be interested in:

Upvotes: 3

Related Questions