This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Prevent GCC from folding inline test functions
- From: Pedro Alves <palves at redhat dot com>
- To: Luis Machado <lgustavo at codesourcery dot com>, gdb-patches at sourceware dot org
- Date: Fri, 21 Aug 2015 17:03:26 +0100
- Subject: Re: [PATCH] Prevent GCC from folding inline test functions
- Authentication-results: sourceware.org; auth=none
- References: <1440162341-26343-1-git-send-email-lgustavo at codesourcery dot com>
On 08/21/2015 02:05 PM, Luis Machado wrote:
> The attached patch implements this by adding the new global variable z, set
> to 0, that gets added in different ways to marker and inlined_fn. Since it
> is 0, it doesn't affect any possible value checks that we may wish to do
> in the future (we currently only check for values changed by bar).
>
> Ok?
>
OK, though you should probably make z volatile as well.
Otherwise, soon enough, gcc with LTO sees that z is always 0:
> +int z = 0;
and then these compile down to the same again, and get folded:
> + x += y - z;
> + x += y + z;
Thanks,
Pedro Alves