[LLVMdev] How to get the module handle of a .bc file??

15102925731 zhenkaixd at 126.com
Tue Apr 10 00:17:43 PDT 2012


 
Hi all,
I want to run a function pass on a certain .bc file. In the process, the pass will insert a check function into the .bc file.

I know the .bc file is regarded as a module in LLVM. So, there are two basic steps needed to be done,
1, Use the "getOrInsertFunction"API to add a declaration of the extern "check function".
2, Use the "insertBefore"API to insert the CallInst into the right position.

My problem is about the step 1. How can I get the handle of the .bc file (Probably is a Module*)? so I can
declare the extern function like
// insert the " i32 @fib(i32 )" to the module M
Function *FibF =
    cast<Function>(M->getOrInsertFunction("fib", Type::getInt32Ty(Context),
                                          Type::getInt32Ty(Context),
                                          (Type *)0));
How can I get the "M" of the .bc file??????

Any help~
 

--

            祝好!
 
  甄凯
------------------------------------------------------------------------------------------------------
2012-04-10
------------------------------------------------------------------------------------------------------
Name: 甄凯(ZhenKai)
Homepage:http://www.renren.com/262729393
Email: zhenkaixd at 126.com or 846227103 at qq.com
TEL: 15810729006(Beijing)
Address: Room I-406, Central Building, Tsinghua University, Beijing, China. 100084.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120410/64a6839e/attachment.html>


More information about the llvm-dev mailing list