[llvm-dev] Zero-sized globals in LLVM IR

Bruce Hoult via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 17 04:16:37 PDT 2018


I believe C says you can't have one. Every variable must have a distinct
address. I don't know what LLVM IR says, but you could maybe insert an asm
label.


On Tue, Jul 17, 2018 at 3:58 AM, David Chisnall via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello the list,
>
> What is the correct type for a global of size zero?  I need the compiler
> to be able to generate one, so that the linker will insert it at a specific
> position without perturbing the location of anything else in the section.
> I have tried a zero-length array (generates something at least one byte).
> At Nuno’s suggestion, I tried a structure with no fields.  In release
> builds, this works correctly, but in debug builds it triggers an assertion
> that the type must be sized.
>
> What is the recommended way of doing this?
>
> David
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180717/8b9bbce1/attachment.html>


More information about the llvm-dev mailing list