How to implement a disable-pass option

Hi ,

I want to implement disable-pass option from command line to disable a specific pass. How can I implement the functionally?

Anyone can help with the process of implementation.

I assume you want a clang command-line option, but there are different ways to get the effect you want, depending on exactly what you want to do.
If you have precisely one pass that you care about, and you will not care about any other passes, then you could modify that pass by adding a cl::opt variable that causes the pass to return without doing anything.
If you are more interested in keeping clang from adding a pass to the pipeline, you would be better off adding the cl::opt to clang\lib\CodeGen\BackendUtil.cpp and modifying the code that constructs the pass pipeline.

If you want a general option that takes an argument saying what pass to disable, that’s a lot more work.

You can write a custom PassInstrumentation to disable certain Passes. More specifically, using PassInstrumentation::runBeforePass. Then, you can register such instrumentation through (new PassManager) Pass plugin via PassBuilder::getPassInstrumentationCallbacks.

I want to disable Transformation passes . I am working with optimization .

My aim is to disable pass one by one for each level of optimization . So , I want to implement a disable-pass in the source code.
If I get any help with idea to implement.

Thanks
Soma

On Tue, Jun 6, 2023, 4:03 PM Min-Yih Hsu via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

mshockwave
June 6

You can write a custom PassInstrumentation to disable certain Passes. More specifically, using PassInstrumentation::runBeforePass. Then, you can register such instrumentation through (new PassManager) Pass plugin via PassBuilder::getPassInstrumentationCallbacks.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

As stated in PassInstrumentation::runBeforePass’s document, if you return false, then the corresponding Pass won’t be executed.

Thank you for your response. I will do and let you know .

On Tue, Jun 6, 2023, 4:11 PM Min-Yih Hsu via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

mshockwave
June 6

As stated in PassInstrumentation::runBeforePass’s document, if you return false, then the corresponding Pass won’t be executed.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

I want to disable multiple passes using the disable-passed flag. I want to implement the functionality . Could you explain how I can execute the disable-passes flag from the clang command line?

What are the files that need to change .

I know implementation of general functionality will be more work but can anyone help to implement disable multiple passes .
I want to read the list of passes from command line and then will exclude from pipeline . If anyone can help me to implement . What are the files need to change . I want to do with opt .

So, the PassInstrumentation idea didn’t work out?

But if you want to do this in opt, rather than clang, that’s much simpler. opt (see llvm/tools/opt/opt.cpp) already lets you do the inverse, specify a list of passes that you do want to run. If that doesn’t meet your needs, then surely you can look at how it handles the parsing of the pass list (look for PassPipeline) as a model for what you do want.

Thanks for your response.

So, the PassInstrumentation idea didn’t work out?

That does not work much . Thanks for suggestion .

But if you want to do this in opt, rather than clang, that’s much simpler. opt (see llvm/tools/opt/opt.cpp) already lets you do the inverse, specify a list of passes that you do want to run. If that doesn’t meet your needs, then surely you can look at how it handles the parsing of the pass list (look for PassPipeline) as a model for what you do want.

#I tried with the command
opt -passes=“pass1, pass2, pass3 …etc” input.ll (is that correct?)
This did not fulfill my requirement. I looked at the opt.cpp and the pass pipeline was created here. My thought was if I get all the passes for each optimization and passestobedisable then can compare passesTobedisable and list of passes and skip passes to add pipeline that are present in passTobedisable .

I don’t understand in which file creates default pipeline and optimization based pipeline .

On Thu, Jun 15, 2023 at 8:14 PM Paul T Robinson via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

pogo59
June 16

So, the PassInstrumentation idea didn’t work out?

But if you want to do this in opt, rather than clang, that’s much simpler. opt (see llvm/tools/opt/opt.cpp) already lets you do the inverse, specify a list of passes that you do want to run. If that doesn’t meet your needs, then surely you can look at how it handles the parsing of the pass list (look for PassPipeline) as a model for what you do want.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

Start by looking at how the PassPipeline string in opt.cpp is used. That string gets handed off somewhere else. Follow the sequence of calls (maybe use grep to find their definitions) to find out how that string is used to construct the set of passes to run. Think about how to pass a second string (passes to disable) and how to use that information to affect how the first string is used.

You will make progress faster, and learn more, by doing this investigation yourself instead of asking other people to do it for you.

I am looking at the codes . Thank you for your response .

On Fri, Jun 16, 2023, 10:43 AM Paul T Robinson via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

pogo59
June 16

soma_p:

I don’t understand in which file creates default pipeline and optimization based pipeline .

Start by looking at how the PassPipeline string in opt.cpp is used. That string gets handed off somewhere else. Follow the sequence of calls (maybe use grep to find their definitions) to find out how that string is used to construct the set of passes to run. Think about how to pass a second string (passes to disable) and how to use that information to affect how the first string is used.

You will make progress faster, and learn more, by doing this investigation yourself instead of asking other people to do it for you.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

At last, I could figure out to disable individual-specific passes.

Thanks for help.

On Fri, Jun 16, 2023 at 10:43 AM Paul T Robinson via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

pogo59
June 16

soma_p:

I don’t understand in which file creates default pipeline and optimization based pipeline .

Start by looking at how the PassPipeline string in opt.cpp is used. That string gets handed off somewhere else. Follow the sequence of calls (maybe use grep to find their definitions) to find out how that string is used to construct the set of passes to run. Think about how to pass a second string (passes to disable) and how to use that information to affect how the first string is used.

You will make progress faster, and learn more, by doing this investigation yourself instead of asking other people to do it for you.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.