Fortran: fix several front-end memleaks
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Dear all,
while looking at the recent testcase gfortran.dg/pr115070.f90 with f951
running under valgrind, I noticed minor front-end memleaks of gfc_expr's
that are probably fallout from a code refactoring, which are fixed by
the attached.
Regtested on x86_64-pc-linux-gnu. OK for mainline?
Thanks,
Harald
Comments
On 10/29/24 2:00 PM, Harald Anlauf wrote:
> Dear all,
>
> while looking at the recent testcase gfortran.dg/pr115070.f90 with f951
> running under valgrind, I noticed minor front-end memleaks of gfc_expr's
> that are probably fallout from a code refactoring, which are fixed by
> the attached.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
> Thanks,
> Harald
>
Yes OK for mainline.
Thanks,
Jerry
Am 29.10.24 um 23:06 schrieb Jerry D:
> On 10/29/24 2:00 PM, Harald Anlauf wrote:
>> Dear all,
>>
>> while looking at the recent testcase gfortran.dg/pr115070.f90 with f951
>> running under valgrind, I noticed minor front-end memleaks of gfc_expr's
>> that are probably fallout from a code refactoring, which are fixed by
>> the attached.
>>
>> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>>
>> Thanks,
>> Harald
>>
>
> Yes OK for mainline.
Pushed as r15-4774-gb8291710e3a6d9.
Thanks,
Harald
> Thanks,
>
> Jerry
>
From 87aaaf3b8614730d0f7ccfe29ee36f4921cf48d2 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Tue, 29 Oct 2024 21:52:27 +0100
Subject: [PATCH] Fortran: fix several front-end memleaks
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_trans_class_init_assign): Free intermediate
gfc_expr's.
* trans.cc (get_final_proc_ref): Likewise.
(get_elem_size): Likewise.
(gfc_add_finalizer_call): Likewise.
---
gcc/fortran/trans-expr.cc | 2 ++
gcc/fortran/trans.cc | 5 +++++
2 files changed, 7 insertions(+)
@@ -1890,6 +1890,8 @@ gfc_trans_class_init_assign (gfc_code *code)
}
gfc_add_expr_to_block (&block, tmp);
+ gfc_free_expr (lhs);
+ gfc_free_expr (rhs);
return gfc_finish_block (&block);
}
@@ -1128,6 +1128,9 @@ get_final_proc_ref (gfc_se *se, gfc_expr *expr, tree class_container)
if (POINTER_TYPE_P (TREE_TYPE (se->expr)))
se->expr = build_fold_indirect_ref_loc (input_location, se->expr);
+
+ if (expr->ts.type != BT_DERIVED && !using_class_container)
+ gfc_free_expr (final_wrapper);
}
@@ -1155,6 +1158,7 @@ get_elem_size (gfc_se *se, gfc_expr *expr, tree class_container)
gfc_conv_expr (se, class_size);
gcc_assert (se->post.head == NULL_TREE);
+ gfc_free_expr (class_size);
}
}
@@ -1467,6 +1471,7 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2,
gfc_add_expr_to_block (block, tmp);
gfc_add_block_to_block (block, &final_se.post);
+ gfc_free_expr (expr);
return true;
}
--
2.35.3