How to disable pass grouping(scheduling)

Hi all,

Llvm can automatically group a list passes. I want to do some experiment to see the difference between grouping and non-grouping execution.
Considering the following example, if I want to apply transformation A, B and C. The execution order is:
   A.doInitialization();
   B.doInitialization();
   C.doInitialization();
   A.runOnFunction();
   B.runOnFunction();
   C.runOnFunction();
   A.doInitialization();
   B.doInitialization();
   C.doInitialization();

Is it possible to disable the grouping? Make it execute as:

   A.doInitialization();
   A.runOnFunction();
   A.doInitialization();
   B.doInitialization();
   B.runOnFunction();
   B.doInitialization();
   C.doInitialization();
   C.runOnFunction();
   C.doInitialization();

Thanks,

Kecheng

Hi all,

Llvm can automatically group a list passes. I want to do some
experiment to see the difference between grouping and non-grouping
execution.
Considering the following example, if I want to apply transformation
A, B and C. The execution order is:
    A.doInitialization();
    B.doInitialization();
    C.doInitialization();
    A.runOnFunction();
    B.runOnFunction();
    C.runOnFunction();
    A.doInitialization();
    B.doInitialization();
    C.doInitialization();

Is it possible to disable the grouping? Make it execute as:

    A.doInitialization();
    A.runOnFunction();
    A.doInitialization();
    B.doInitialization();
    B.runOnFunction();
    B.doInitialization();
    C.doInitialization();
    C.runOnFunction();
    C.doInitialization();

Thanks,

You can run opt three times (one for each pass A, B, and C), piping them together so that the output of one is the input to the next.

-- John T.

Thanks John, this is an easy way to achieve this goal, but I'm wondering if this is the only way? I have around 100 passes.

Quoting John Criswell <criswell@illinois.edu>:

Thanks John, this is an easy way to achieve this goal, but I'm wondering if this is the only way? I have around 100 passes.

You might be able to do this by writing a program that uses multiple Pass Manager objects to run the passes, but I'm not sure if that will work; perhaps someone more knowledgeable on PassManager internals can comment.

Just out of curiosity, why are you trying to do this? The doInitialization() and doFinalization() methods, I believe, are typically used for some global setup/cleanup for a FunctionPass (e.g., to add a function declaration so that the FunctionPass can add calls to that function); as such, they usually don't do much, and their relative order of execution shouldn't really matter.

-- John T.

You could also use the API, e.g.

RunPass(Pass* p) {
  PassManager pm;
  pm.add(p);
  pm.run(M)
}

...
RunPass(createAPass());
RunPass(createBPass());
RunPass(createCPass());
...

Is your goal just to see the performance lost from having to recompute
analyses that would otherwise be preserved and reused?