llvm-tutor icon indicating copy to clipboard operation
llvm-tutor copied to clipboard

New examples

Open unterumarmung opened this issue 3 years ago • 3 comments

Hi! Thank you for creating such a useful resource to learn about LLVM!

I have some questions about LLVM out-of-source development that you can probably answer

  1. Can I change a pipeline of optimizations passes from my own pass / plugin? If yes, can you please share some some docs about it or perhaps make an example?
  2. Can I forbid default LLVM passes to run on specific functions? If yes, how?

Thank you in advance!

unterumarmung avatar Jan 29 '22 20:01 unterumarmung

Also, I'm wondering, how can I run multiple passes in a single plugin?

unterumarmung avatar Jan 29 '22 20:01 unterumarmung

There are not a lot of examples out there using new pass manager with out-of-tree plugins

unterumarmung avatar Jan 29 '22 20:01 unterumarmung

Hi @unterumarmung , thanks for using llvm-tutor!

Hi! Thank you for creating such a useful resource to learn about LLVM!

I'm really glad that it's been helpful, thank you for your kind feedback :)

Can I change a pipeline of optimizations passes from my own pass / plugin?

Hm, a pass and a pass pipeline are two different things. These things are related, but that relation usually boils down to: "this" pass pipeline includes "that" pass. So, AFAIK, the answer is "no".

Can I forbid default LLVM passes to run on specific functions? If yes, how?

You want to specify the optimisation level on a per-function basis. AFAIK, that's not available. You can use function attributes (and could define your own), but there's nothing "generic". Function attributes are documented here.

Also, I'm wondering, how can I run multiple passes in a single plugin?

Hm, a plugin just implements a pass. You then use a driver (e.g. opt) to load it and to run it. But you could try defining a transformation pass that depends on some analysis pass. I've been meaning to add something like this to llvm-tutor, but haven't had the bandwidth :( Patches welcome! :)

There are not a lot of examples out there using new pass manager with out-of-tree plugins

What's the situation with the Legacy PM? Is it better?

Thanks, -Andrzej

banach-space avatar Jan 30 '22 18:01 banach-space

Closing as there's been no new activity in over 6 months now. Please feel free to re-open if you have more questions.

banach-space avatar Sep 08 '22 09:09 banach-space