llvm-tutor icon indicating copy to clipboard operation
llvm-tutor copied to clipboard

how can I run pass on specific functions?

Open meweez opened this issue 3 years ago • 3 comments

hello, I have a question.

  1. is there any way to run the function pass(runOnFunction) on a specific function that gets the function name from the user? I mean can I pass some input to runOnFunction?

Thanks a lot

meweez avatar Apr 20 '21 18:04 meweez

Hi,

As far as I know, you can't control when runOnFunction is run and on what input it runs. That's what the pass manager is responsible for. But I haven't tried it myself.

Instead, I'd start by checking function name inside your pass and skip it for all functions but the one you are interested in. Also, there's optnone and other function attributes that you could use.

I hope that this helps!

banach-space avatar Apr 21 '21 08:04 banach-space

Hi, I used an if condition based on function name like below:

bool runOnFunction(Function &F)
{
    if (F.getName() == "xxx"){
    //do things
    }

}

but The pass did the statements in the if the condition for xxx and all function after the xxx. Do you know why? Thanks

meweez avatar Jun 21 '21 05:06 meweez

Hey @me22bee ,

It's hard to tell without a reproducer or a complete example.

-Andrzej

banach-space avatar Jun 22 '21 08:06 banach-space

Closing as there's been no traffic here for a quite a while now. Please re-open if you have more questions!

banach-space avatar Nov 18 '22 10:11 banach-space