Re: [PATCH] Prevent GCC from folding inline test functions

Pedro Alves
2015-08-21T16:03:30Z

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