[LLVMdev] questions about context

Eli Friedman eli.friedman at gmail.com
Wed Aug 18 20:02:43 PDT 2010


On Wed, Aug 18, 2010 at 7:41 PM, Guoliang Jin <jingl1345 at gmail.com> wrote:
>  Hi,
>
> I am trying to load another bytecode file in one pass.
>
> I checked the opt.cpp, it uses following to load a bytecode file:
> ...
>   LLVMContext &Context = getGlobalContext();
>
> ...
>
>   SMDiagnostic Err;
>
>   // Load the input module...
>   std::auto_ptr<Module> M;
>   M.reset(ParseIRFile(InputFilename, Err, Context));
> ...
>
> My question is in the runOnModule method where I want to load another
> bytecode file, what context should I use? Is getGlobalContext() still OK?

That's not necessarily the appropriate context; use M.getContext(),
where M is the Module& passed into runOnModule.

-Eli




More information about the llvm-dev mailing list