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

Than McIntosh via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 18 09:18:22 PDT 2018


Hi David,

You wrote
>>>but in debug builds it triggers an assertion that the type must be sized

I am curious as to which specific assert you're encountering.

Context: zero-sized structures and arrays are legal in the Go language; so
far in our (in-progress) gollvm work we haven't seen issues or asserts with
these sorts of constructs.

Thanks, Than

On Tue, Jul 17, 2018 at 6:59 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/20180718/990414af/attachment.html>


More information about the llvm-dev mailing list