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

Hello,

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.

Summarising,

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

Sanjay

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:
http://llvm.org/doxygen/structllvm_1_1RegisterStandardPasses.html

In Polly, you can find the registration part a bit further down in the file you linked: https://github.com/llvm-mirror/polly/blob/master/lib/Support/RegisterPasses.cpp#L417

Cheers,
Philip

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.

Michael

Thanks for the information !!