[llvm-dev] What is the proper usage of LLVMContext?

via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 21 06:15:42 PST 2017


Hi, I'm Ryo Ota. I have two questions about `llvm::LLVMContext`.

Q1) What is the difference between the following (A)`my_context` and
(B)`global_context`?
Do I have to create a LLVMContext by myself? Or use `getGlobalContext()`?
Could you tell me what situation needs a LLVMContext which is created by
myself such as (A)?

(A)
{
llvm::LLVMContext my_context;
// codes using only my_context (get Int32ty() or StructType::create or
etc...)
}

(B)
{
llvm::LLVMContext &globa_context = llvm::getGlobalContext();
// codes using only globa_context (get Int32ty() or StructType::create or
etc...)
}


Q2) What situation do I need to create multiple `LLVMContext`s?
I don't know the situation used multiple `LLVMContext`s.

For example,
{
{
llvm::LLVMContext ctx1;
// some code
}

{
llvm::LLVMContext ctx2;
// some code
}

{
llvm::LLVMContext ctx3;
// some code
}
}

or

{
llvm::LLVMContext ctxs[] = {....}
// some code
}

I'd like to know the appropriate usage of LLVMContext. Thak you very much
for reading.

Sincerely,

Ryo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170221/19ca2a2c/attachment.html>


More information about the llvm-dev mailing list