[LLVMdev] Operations on constant array value?

Garrison Venn gvenn.cfe.dev at gmail.com
Mon Jan 11 14:55:09 PST 2010


Sorry to keep this thread alive, but I'm learning so ...

There is more. The doc for GlobalValue::LinkageTypes or the C API LLVMLinkage is not as clear as the
lang ref manual. See: http://llvm.org/docs/LangRef.html#linkage. I'm pointing this out because something
like LinkerPrivateLinkage (LLVMLinkerPrivateLinkage), or another one, might be more appropriate to 
your throw away use case (if I understand your use correctly). One should test this of course, and/or one 
of the experts could chime in hint hint. :-)

Anyway thought this info. might be useful, however rehashed. 

Garrison

On Jan 11, 2010, at 16:34, James Williams wrote:

> 2010/1/11 Garrison Venn <gvenn.cfe.dev at gmail.com>
> I have not tried this, but a linkage type of PrivateLinkage would not add to the symbol table according
> to the doc. 
> 
> LLVMSetLinkage(g, LLVMPrivateLinkage);
> 
> Thanks - I hadn't thought of that.
> 
> Garrison
> 
> On Jan 11, 2010, at 14:03, James Williams wrote:
> 
>> 2010/1/11 Eli Friedman <eli.friedman at gmail.com>
>> On Mon, Jan 11, 2010 at 7:07 AM, James Williams <junk at giantblob.com> wrote:
>> > Hi,
>> >
>> > I've read http://llvm.org/docs/LangRef.html#t_array and
>> > http://llvm.org/docs/GetElementPtr.html and if I've understood right there
>> > are no operations that act directly on arrays - instead I need to use
>> > getelementptr on a pointer to an array to get a pointer to an array element.
>> > I also understand that there is no 'address of' operation.
>> >
>> > As a result I can't figure out how to use constant derived types without
>> > assigning them to a global. Say I want to use the C bindings function
>> > LLVMValueRef LLVMConstString(char *, int, int) to get an int8* pointer to a
>> > C string constant - there doesn't seem to be any way to directly use the
>> > resulting [N x i8] value directly and there's no operator that gives me its
>> > address.
>> >
>> snip
>> >
>> > Is it possible to get the address of an element of a constant array or
>> > struct without first initializing a global variable to the constant?
>> 
>> No.
>> 
>> OK. I'd have preferred to have to avoid bloating the module symbol table with global symbols that will never be referenced but it's no big deal.
>> 
>> -Eli
>> 
>> 
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100111/f86ce73d/attachment.html>


More information about the llvm-dev mailing list