This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][GCC] Make stackalign test LTO proof
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Andre Vieira <Andre dot SimoesDiasVieira at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Nov 2015 15:31:55 +0100
- Subject: Re: [PATCH][GCC] Make stackalign test LTO proof
- Authentication-results: sourceware.org; auth=none
- References: <5644AB37 dot 3050201 at arm dot com> <CAFiYyc0416DpS2RwWRAOC2HoUPP1U2DSwfksektXwyB2=bRT0w at mail dot gmail dot com> <5649C158 dot 50903 at arm dot com> <CAFiYyc2kEj+RbbJ1=0atc6L1vHVNbQwmt5xtLAsgHJ69Tf81-Q at mail dot gmail dot com> <5649E35B dot 608 at arm dot com>
On Mon, Nov 16, 2015 at 3:08 PM, Andre Vieira
<Andre.SimoesDiasVieira@arm.com> wrote:
> On 16/11/15 13:33, Richard Biener wrote:
>>
>> On Mon, Nov 16, 2015 at 12:43 PM, Andre Vieira
>> <Andre.SimoesDiasVieira@arm.com> wrote:
>>>
>>> On 13/11/15 10:34, Richard Biener wrote:
>>>>
>>>>
>>>> On Thu, Nov 12, 2015 at 4:07 PM, Andre Vieira
>>>> <Andre.SimoesDiasVieira@arm.com> wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> This patch changes this testcase to make sure LTO will not optimize
>>>>> away
>>>>> the assignment of the local array to a global variable which was
>>>>> introduced
>>>>> to make sure stack space was made available for the test to work.
>>>>>
>>>>> This is correct because LTO is supposed to optimize this global
>>>>> away
>>>>> as at
>>>>> link time it knows this global will never be read. By adding a read of
>>>>> the
>>>>> global, LTO will no longer optimize it away.
>>>>
>>>>
>>>>
>>>> But that's only because we can't see that bar doesn't clobber it, else
>>>> we would optimize away the check and get here again. Much better
>>>> to mark 'dummy' with __attribute__((used)) and go away with 'g'
>>>> entirely.
>>>>
>>>> Richard.
>>>>
>>>>> Tested by running regressions for this testcase for various ARM
>>>>> targets.
>>>>>
>>>>> Is this OK to commit?
>>>>>
>>>>> Thanks,
>>>>> Andre Vieira
>>>>>
>>>>> gcc/testsuite/ChangeLog:
>>>>> 2015-11-06 Andre Vieira <andre.simoesdiasvieira@arm.com>
>>>>>
>>>>> * gcc.dg/torture/stackalign/builtin-return-1.c: Added read
>>>>> to global such that a write is not optimized away by LTO.
>>>>
>>>>
>>>>
>>> Hi Richard,
>>>
>>> That would be great but __attribute__ ((used)) can only be used for
>>> static
>>> variables and making dummy static would defeat the purpose here.
>>
>>
>> I see. What about volatile?
>>
>>> Cheers,
>>> Andre
>>>
>>
> Yeh a 'volatile char dummy[64];' with a read afterwards leads to the stack
> still being reserved after LTO and we won't need the global variable.
>
> If you prefer that solution Ill respin the patch.
Yes please.
Richard.
> Cheers,
> Andre
>