From f3941af5d3c81827be43b0596c12c0df572fc28e Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 23 Jan 2012 10:52:57 +0000 Subject: [PATCH] 2012-01-23 Richard Guenther PR tree-optimization/51949 * ipa-split.c (execute_split_functions): Do not split malloc functions. * gcc.dg/torture/pr51949.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183424 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/ipa-split.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr51949.c | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr51949.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80f124a..60697f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-01-23 Richard Guenther + + PR tree-optimization/51949 + * ipa-split.c (execute_split_functions): Do not split malloc + functions. + 2012-01-23 Jakub Jelinek PR rtl-optimization/51933 diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 09e04af..124098ce 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -1395,10 +1395,11 @@ execute_split_functions (void) int todo = 0; struct cgraph_node *node = cgraph_get_node (current_function_decl); - if (flags_from_decl_or_type (current_function_decl) & ECF_NORETURN) + if (flags_from_decl_or_type (current_function_decl) + & (ECF_NORETURN|ECF_MALLOC)) { if (dump_file) - fprintf (dump_file, "Not splitting: noreturn function.\n"); + fprintf (dump_file, "Not splitting: noreturn/malloc function.\n"); return 0; } if (MAIN_NAME_P (DECL_NAME (current_function_decl))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dee2c0d..1abdae7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-23 Richard Guenther + + PR tree-optimization/51949 + * gcc.dg/torture/pr51949.c: New testcase. + 2012-01-23 Jakub Jelinek PR rtl-optimization/51933 diff --git a/gcc/testsuite/gcc.dg/torture/pr51949.c b/gcc/testsuite/gcc.dg/torture/pr51949.c new file mode 100644 index 0000000..e23bd7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr51949.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef long unsigned int size_t; +extern __attribute__ ((malloc)) void *mem_alloc(size_t); +void *mem_alloc(size_t amount) +{ + void *q = __builtin_malloc (amount); + if (!q) { + __builtin_printf("malloc"); + __builtin_exit(255); + } +} +void mem_realloc() +{ + mem_alloc(1); +} +void put_env_var() +{ + mem_alloc(1); +} -- 2.7.4