Adaptors in new pass manager


I have 4 questions:

  1. In legacy pass manager, we have following sequence of code in PassManagerBuilder.cpp

PM.add( some_function_pass_1() )
PM.add( some_function_pass_2() )

why is it that we add function pass to a module pass manager? And does these 2 statements create 2 function pass managers ?

  1. In new pass manager, the above code would look something like this.
    FunctionPassManager FPM;
    FPM.add( some_function_pass_1() )
    FPM.add( some_function_pass_2() )

MPM.add( std::move(FPM) )

Now is this code exactly identical to code in legacy pass manager shown above or how is it different?

  1. Can adaptors be used in custom pass to change the schedule of pipeline?

  2. Can adaptors be used to decide on the sequence of passes to be run such that sequence yields better results? By deciding I mean searching/trying out different sequences(like we search for good solutions in machine learning)