This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Go patch committed: Fix passing zero-sized global variable to function
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Ian Lance Taylor <iant at golang dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, "gofrontend-dev at googlegroups dot com" <gofrontend-dev at googlegroups dot com>
- Date: Mon, 21 Dec 2015 16:19:40 -0800
- Subject: Re: Go patch committed: Fix passing zero-sized global variable to function
- Authentication-results: sourceware.org; auth=none
- References: <CAOyqgcVLk_pBFm8_yn1zPbhrmA0TZzZxrgJea63xmZDTzbs0MQ at mail dot gmail dot com>
On Mon, Dec 21, 2015 at 4:10 PM, Ian Lance Taylor <iant@golang.org> wrote:
> The GNU linker doesn't support a zero-sized global variable that is
> dynamically exported, so gccgo generates those global variables with a
> size of 1 byte. Unfortunately, that means that passing a global
> variable to a function that takes an argument of a zero-sized type
> will actually pass 1 byte, taking up an argument slot, rather than a
> zero-sized argument that should be skipped. This patch fixes the
> problem in the Go frontend -> GCC interface by adding a conversion to
> the real type for any such global variables, and undoing the
> conversion where necessary. Bootstrapped and ran Go testsuite on
> x86_64-pc-linux-gnu. Committed to mainline and gccgo branch.
VIEW_CONVERT_EXPR on different size types is invalid for GCC's IR.
So this patch cause other issues.
Thanks,
Andrew Pinski
>
> Ian
>
> 2015-12-21 Ian Lance Taylor <iant@google.com>
>
> * go-gcc.cc (Gcc_backend::global_variable): If type is zero-sized,
> add a VIEW_CONVERT_EXPR to the tree.
> (Gcc_backend::global_variable_set_init): Remove any
> VIEW_CONVERT_EXPR.
> (Gcc_backend::write_global_definitions): Likewise.