Creating a copy Pass of DependenceAnalysis

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).

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.

So, what should I do? What is the “correct” to create the copy; like an external
library as the HelloWorld tutorial shows ?

Thanks,
Stefanos

[1] https://github.com/baziotis/llvm-project/tree/dep_analysis
[2] https://www.youtube.com/watch?v=ar7cJl2aBuU

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

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

Oh ok, I’ll try it.

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

I’ll take a look, but the way I see it, copying passes ends up being more complicated.

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.

I don’t necessarily want an in-tree pass and the way I see it I better stick to:

  • Old pass manager
  • Out-of-tree passes

at least for now.

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

Yep, I know, although I have to look more into that. The thing is, I pretty much understand all the theoretical background of DependenceAnalysis,
the way it is implemented is very clear and I somewhat can think how to use its dependence tests to create run-time checks.
So I wanted to experiment to see how much of LoopAccessAnalysis I’ll need.

Because LoopAccessAnalysis on the other hand, maybe partly because it’s focused on the loop vectorizer, is not at all clear to me. :slight_smile:

Thanks for the help,
Stefanos

Στις Παρ, 22 Μαΐ 2020 στις 6:20 μ.μ., ο/η Florian Hahn <florian_hahn@apple.com> έγραψε: