[llvm-dev] Creating a copy Pass of DependenceAnalysis

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Fri May 22 08:20:00 PDT 2020



> On May 22, 2020, at 15:42, Stefanos Baziotis via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> I want to create a copy of DependenceAnalysis downstream.
> 
> At first I tried the HelloWorld tutorial. But then I figured, maybe I should move on
> to create my pass by mimicking some other pass in LLVM.
> 
> So, I tried copying DependenceAnalysis itself [1]
> 
> Although after a lot of time of trying it compiled, I'm pretty sure I have done it
> completely in the wrong way. What is more, I can't access my pass with the argument
> I put (-rt-dep-checks).
> 

For the new pass manager I think you have to add your pass to llvm/lib/Passes/PassRegistry.def. 

I’d recommend taking a look at how the DominatorTree analysis is set up. Also note that analysis passes on their own are invoked a little bit differently to transformation passes: old PM:  `opt -domtree -analyze foo.ll`, new PM: `opt  -passes='print<domtree>’ foo.ll`

> Then, I watched this tutorial [2]. Apart from the fact that there seem to be
> way too many steps just to create hello world pass, I don't think that passes like
> DependenceAnalysis follow it.

IIRC the tutorial is mostly focusing on out-of-tree passes, so the steps are different to an in-tree pass. It looks like the in-tree docs also mostly cover out-of-tree passes (http://llvm.org/docs/WritingAnLLVMPass.html). Improvements to the docs in that area would definitely be welcomed.


> [1] https://github.com/baziotis/llvm-project/tree/dep_analysis

I had a quick look and it looks like your new pass is called RuntimeDependenceChecks. 

Just in case you are not aware, there is already infrastructure to create runtime checks for dependences in loops in tree: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/LoopAccessAnalysis.cpp

Cheers,
Florian


More information about the llvm-dev mailing list