diff mbox

[04/N] Fix big memory leak in ix86_valid_target_attribute_p

Message ID 5644B5B0.6040703@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 12, 2015, 3:52 p.m. UTC
On 11/12/2015 12:29 PM, Richard Biener wrote:
> On Thu, Nov 12, 2015 at 11:03 AM, Martin Liška <mliska@suse.cz> wrote:
>> Hello.
>>
>> Following patch was a bit negotiated with Jakub and can save a huge amount of memory in cases
>> where target attributes are heavily utilized.
>>
>> Can bootstrap and survives regression tests on x86_64-linux-pc.
>>
>> Ready for trunk?
> 
> +static bool opts_obstack_initialized = false;
> +
> +/* Initialize opts_obstack if not initialized.  */
> +
> +void
> +init_opts_obstack (void)
> +{
> +  if (!opts_obstack_initialized)
> +    {
> +      opts_obstack_initialized = true;
> +      gcc_obstack_init (&opts_obstack);
> 
> you can move the static global to function scope.
> 
> Ok with that change.

Done and installed as r230264. Final version of the patch is attached.

> 
> Btw, don't other targets need a similar adjustment to their hook?
> Grepping shows arm and nios2.

nios2 is not the case as it doesn't utilize:
  init_options_struct (&func_options, NULL);

I've been testing patch for aarch64 that is also included in the email.

Martin

> 
> Thanks,
> Richard.
> 
> 
>> Thanks,
>> Martin

Comments

Ramana Radhakrishnan Nov. 12, 2015, 3:58 p.m. UTC | #1
On 12/11/15 15:52, Martin Liška wrote:
> On 11/12/2015 12:29 PM, Richard Biener wrote:
>> On Thu, Nov 12, 2015 at 11:03 AM, Martin Liška <mliska@suse.cz> wrote:
>>> Hello.
>>>
>>> Following patch was a bit negotiated with Jakub and can save a huge amount of memory in cases
>>> where target attributes are heavily utilized.
>>>
>>> Can bootstrap and survives regression tests on x86_64-linux-pc.
>>>
>>> Ready for trunk?
>>
>> +static bool opts_obstack_initialized = false;
>> +
>> +/* Initialize opts_obstack if not initialized.  */
>> +
>> +void
>> +init_opts_obstack (void)
>> +{
>> +  if (!opts_obstack_initialized)
>> +    {
>> +      opts_obstack_initialized = true;
>> +      gcc_obstack_init (&opts_obstack);
>>
>> you can move the static global to function scope.
>>
>> Ok with that change.
> 
> Done and installed as r230264. Final version of the patch is attached.
> 
>>
>> Btw, don't other targets need a similar adjustment to their hook?
>> Grepping shows arm and nios2.
> 
> nios2 is not the case as it doesn't utilize:
>   init_options_struct (&func_options, NULL);
> 
> I've been testing patch for aarch64 that is also included in the email.

The change is also needed in config/aarch64/aarch64.c (aarch64_option_valid_attribute_p). The attached patch is for arm i.e. 32 bit arm.

Ramana

> 
> Martin
> 
>>
>> Thanks,
>> Richard.
>>
>>
>>> Thanks,
>>> Martin
>
Martin Liška Nov. 12, 2015, 4:24 p.m. UTC | #2
On 11/12/2015 04:58 PM, Ramana Radhakrishnan wrote:
> 
> 
> On 12/11/15 15:52, Martin Liška wrote:
>> On 11/12/2015 12:29 PM, Richard Biener wrote:
>>> On Thu, Nov 12, 2015 at 11:03 AM, Martin Liška <mliska@suse.cz> wrote:
>>>> Hello.
>>>>
>>>> Following patch was a bit negotiated with Jakub and can save a huge amount of memory in cases
>>>> where target attributes are heavily utilized.
>>>>
>>>> Can bootstrap and survives regression tests on x86_64-linux-pc.
>>>>
>>>> Ready for trunk?
>>>
>>> +static bool opts_obstack_initialized = false;
>>> +
>>> +/* Initialize opts_obstack if not initialized.  */
>>> +
>>> +void
>>> +init_opts_obstack (void)
>>> +{
>>> +  if (!opts_obstack_initialized)
>>> +    {
>>> +      opts_obstack_initialized = true;
>>> +      gcc_obstack_init (&opts_obstack);
>>>
>>> you can move the static global to function scope.
>>>
>>> Ok with that change.
>>
>> Done and installed as r230264. Final version of the patch is attached.
>>
>>>
>>> Btw, don't other targets need a similar adjustment to their hook?
>>> Grepping shows arm and nios2.
>>
>> nios2 is not the case as it doesn't utilize:
>>   init_options_struct (&func_options, NULL);
>>
>> I've been testing patch for aarch64 that is also included in the email.
> 
> The change is also needed in config/aarch64/aarch64.c (aarch64_option_valid_attribute_p). The attached patch is for arm i.e. 32 bit arm.
> 
> Ramana

You are right that the change is for arm32, I wrongly wrote aarch64. However if you read
aarch64_option_valid_attribute_p, there is no init_options_struct (&func_options, NULL).

So that, I'm going to test on an arm32 machine.

Martin

> 
>>
>> Martin
>>
>>>
>>> Thanks,
>>> Richard.
>>>
>>>
>>>> Thanks,
>>>> Martin
>>
diff mbox

Patch

From b2a7dcae8de93db470da0b35162f5538337320ee Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 12 Nov 2015 16:41:16 +0100
Subject: [PATCH] Finalize func_options in arm target in
 arm_valid_target_attribute_p

gcc/ChangeLog:

2015-11-12  Martin Liska  <mliska@suse.cz>

	* config/arm/arm.c (arm_valid_target_attribute_p): Finalize
	options struct.
---
 gcc/config/arm/arm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index f4ebbc8..941774b 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -29956,6 +29956,8 @@  arm_valid_target_attribute_p (tree fndecl, tree ARG_UNUSED (name),
 
   DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize;
 
+  finalize_options_struct (&func_options);
+
   return ret;
 }
 
-- 
2.6.2