[LLVMdev] First steps with LLVM and partial evaluation
Nick Lewycky
nicholas at mxc.ca
Wed Jul 6 10:39:08 PDT 2011
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