Passes after Polly | How are Passes sequenced without the PassRegistry ?


I was trying to find out what passes are sequenced after Polly in clang. I need to know this since I’m seeing a difference between the files kernel-before.ll and kernel.ll generated by the command clang -g -O3 -mllvm -polly -mllvm -polly-dump-before -S -emit-llvm, where kernel-before.ll is the file received by Polly.

I assumed that the clang driver registers the Passes just like opt or Julia does by calling polly::registerPollyPasses ( in the <polly_src>/lib/Support/RegisterPasses.cpp ). But, it was a surprise to not find a call to registerPollyPasses inside clang.


  • How is Polly called from Clang ?
  • What are the Passes sequenced after Polly ?


The PassManagerBuilder that constructs the -O pipelines offers multiple ExtensionPoints at which optimizer plugins can insert themselves into optimizer pipelines.

Here’s how plugins can do this:

In Polly, you can find the registration part a bit further down in the file you linked:


How is Polly called from Clang ?

Polly registers itself to the PassBuilderBuilder using
llvm::RegisterStandardPasses. clang will then call
PassManagerBuilder::populateModulePassManager and get a PassManager
with Polly in it.

What are the Passes sequenced after Polly ?

If you look into the source of
PassManagerBuilder::populateModulePassManager, you can see where Polly
is added. There are multiple positions possible (addExtensionsToPM),
determined by the -polly-position= switch.


Thanks for the information !!