excavator
excavator

Reputation: 403

Get current module inside FunctionPass llvm

I'm writing a function pass in LLVM and need to call the method Module::getOrInsertFunction. I need to access the module of the current function. How do I get it?

Upvotes: 5

Views: 5151

Answers (2)

Arvind Sudarsanam
Arvind Sudarsanam

Reputation: 31

Please refer to: http://llvm.org/docs/WritingAnLLVMPass.html According to the documentation here, To be explicit, FunctionPass subclasses are not allowed to: 1. Inspect or modify a Function other than the one currently being processed. 2. Add or remove Functions from the current Module. 3. Add or remove global variables from the current Module. 4. Maintain state across invocations of runOnFunction (including global data).

So, you cannot call getOrInsertFunction from inside a FunctionPass. You will need a ModulePass

Upvotes: 3

Related Questions