2

What I'm trying to achieve here is simple. I need my pass to go through the functions in a file (and hence, FunctionPass) and check if one of them is the one I'm looking for. I want to achieve this in a clean, simple way.

So far, I'm extracting the following info from the functions in the file I'm running the pass over:

  • Name
  • Return Type
  • Number + type of arguments

I already have this info for the function I'm looking for and I've thought about comparing this info with the one extracted to see if there's a match.

But is there a better way of doing this?

mikasa
  • 783
  • 1
  • 11
  • 29
  • You can try Module->getFunction(StringRef name) if you have the name of the function in modulePass. ref: http://llvm.org/doxygen/classllvm_1_1Module.html#a209a615a3a32241323420cca24b5520a – Chirag Patel Feb 25 '18 at 18:34
  • Seems like a good approach... I'll try it out in a couple of days and update here if I have any success! – mikasa Feb 26 '18 at 16:41
  • Works like a charm. Thank you! You can add your comment as an answer and I'll mark it as correct if you want to. – mikasa Apr 16 '18 at 19:03
  • Good to hear that, just added the answer mark it as solved. – Chirag Patel Apr 16 '18 at 20:21

1 Answers1

1

You can try Module->getFunction(StringRef name) if you have the name of the function in modulePass.
see: llvm::Module Class Reference

Chirag Patel
  • 1,141
  • 1
  • 11
  • 23