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

Alexander Potapenko glider at google.com
Tue Apr 10 00:29:15 PDT 2012


Objects that form the IR (functions, basic blocks, instructions) have
the getParent() method that returns their paren (module for a
function, basic block for a single instruction etc.)
BTW, LLVM Doxygen is really helpful. It's usually the first result
when you search for "LLVM <classname> class reference"

On Tue, Apr 10, 2012 at 11:17 AM, 15102925731 <zhenkaixd at 126.com> wrote:
>
> 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.
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
Alexander Potapenko
Software Engineer
Google Moscow




More information about the llvm-dev mailing list