llvm-tutor
llvm-tutor copied to clipboard
how can I run pass on specific functions?
hello, I have a question.
- 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 torunOnFunction
?
Thanks a lot
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!
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
Hey @me22bee ,
It's hard to tell without a reproducer or a complete example.
-Andrzej
Closing as there's been no traffic here for a quite a while now. Please re-open if you have more questions!