This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] New fixes for hot/cold partitioning
Zack Weinberg <zack@codesourcery.com> writes:
> Okay, so what you should do is have a pointer in cfun which is either
> set equal to the fixed name for the shared cold section (which is a
> string literal) or set equal to the name for the per-function cold
> section, which is allocated with ggc_alloc_string. It is safe for a
> const char* in GC space to point to a string literal, if I remember
> correctly. (Check with Geoff.) The garbage collector will then
> handle the de-allocation problem.
Yes, it's safe for a char * to point to a string literal. However,
you should not assume that it will keep pointing to a string literal;
that is, if you need to compare them, you need to use strcmp() not '=='.