This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] - Proper hot/cold partitioning fixes patch.
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: Caroline Tice <ctice at apple dot com>, "gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 28 Apr 2005 12:16:32 +0100
- Subject: Re: [PATCH] - Proper hot/cold partitioning fixes patch.
- References: <e4eeba8ec28ffa69e99ce5e43eb3ac67@apple.com><87vf68n12i.fsf@codesourcery.com>
Zack Weinberg <zack@codesourcery.com> writes:
> In general the use of alloca is discouraged, but this is a perfect
> example of a place where it *should* be used. Like so:
>
> assert (cfun && current_function_decl);
> if (cfun->unlikely_text_section_name)
> return;
>
> if (flag_function_sections && DECL_SECTION_NAME (current_function_decl))
> {
> name = alloca (TREE_STRING_LENGTH (DECL_SECTION_NAME
> (current_function_decl)));
> strcpy (name, TREE_STRING_POINTER (DECL_SECTION_NAME
> (current_function_decl)));
> stripped_name = targetm.strip_name_encoding (name);
> buffer = alloca (strlen (stripped_name) + 10);
> strcpy (buffer, stripped_name);
> strcat (buffer, "_unlikely");
> cfun->unlikely_text_section_name = ggc_strdup (buffer);
> }
> else
> cfun->unlikely_text_section_name = UNLIKELY_EXECUTED_TEXT_SECTION_NAME;
>
> It's still not pretty, though. Seems to me there ought to be a better
> way, but I don't know one.
It could probably be simplied slightly by using ACONCAT from
libiberty.h. E.g.:
buffer = ACONCAT ((stripped_name, "_unlikely", NULL));
Richard