[LLVMdev] Getting a named value in llvm-c

Duncan Sands baldrick at free.fr
Wed Nov 21 01:35:45 PST 2012

Hi Bill,

> I am wondering if there is a way to get a value by name in the C
> interface for the LLVM Jit?

since a Value includes simple constants like 42 that have no name, this is
not possible in general.  Moreover names are usually optional and have no
real meaning: they are just there to make the IR easier to read (an exception
being struct type names).

Perhaps you could maintain a map from name to Value* in your front-end?

Ciao, Duncan.

> There seems to be a way to name values consistently, but no way to
> retrieve those LLVMValueRef's by name.
> I see it is possible to get a struct by name and a type by name and a
> function by name, and a few other esoteric things, but not a general
> value.
> The reason I am wanting this is that I am writing a language where
> there is a separation between the back end and the code which
> processes the AST. In particular, I do not have any LLVM values or
> types in the AST nodes themselves, only strings naming those values
> and types. When the back end processes the AST it looks up the
> relevant types and values by string name.
> The specific circumstance where this causes an issue is with
> allocating local variables. The back end code needs to access such
> variables at points different from where they were defined. At present
> I have to store the relevant LLVMValueRef's in the AST or in some
> other type information elsewhere in my implementation, rather than
> store a string name and look them up as needed.
> Bill.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list