[LLVMdev] First steps with LLVM and partial evaluation

Martin Apel martin.apel at SIMPACK.de
Thu Jul 7 00:18:48 PDT 2011


Hi Nick,

thanks a lot, this did the trick. I tried to define my own context as locally as I could, but this didn't help. Now that I know, what I had to look
for, I even found the place in the documentation, where this is described.

Martin

On 06/07/11 19:39, Nick Lewycky wrote:
> Martin Apel wrote:
>> static LLVMContext context;
> That's your bug.
>
> Here's the situation that contexts help with. Suppose you write a
> library that uses LLVM under the hood (graphics, let's say), and I write
> another one that uses LLVM and does audio processing. Someone then
> decides to write a video game that uses both of our libraries. As long
> as we each use a separate context, everything about llvm will stay
> entirely and completely segregated and we'll never interfere with each
> other.
>
> The module and the function your pass runs on and all of the types in it
> were created with a certain LLVMContext, but then you tried to mix your
> own LLVMContext in there. Don't do that, always pull the context from
> the IR that you're given. llvm::Value has a getContext() method on it.
>
> Nick
>




More information about the llvm-dev mailing list