This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Functions that are CSEable but not pure


On 10/04/2012 01:42 PM, Richard Guenther wrote:
So I suppose the testcase that would be "valid" but break with using
pure would be instead

int main()
{
   int x = init_count;
   int *p = get_me();
   if (init_count == x)
     __builtin_abort();
   int *q = get_me();
   if (init_count == x)
     __builtin_abort();
}

here when get_me is pure we CSE init_count over the _first_ call of get_me.

That's OK for C++ thread_local semantics; the initialization is specified to happen some time before the first use, so the testcase is making an invalid assumption. This might not be desirable for user-written singleton functions, though.


Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]