This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [google gcc-4_8] Don't use gcov counter related ssa name as induction variables
- From: Xinliang David Li <davidxl at google dot com>
- To: Wei Mi <wmi at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Rong Xu <xur at google dot com>, Easwaran Raman <eraman at google dot com>
- Date: Tue, 11 Feb 2014 10:42:23 -0800
- Subject: Re: [google gcc-4_8] Don't use gcov counter related ssa name as induction variables
- Authentication-results: sourceware.org; auth=none
- References: <CA+4CFy5-zioKc0nd2OLsG84TrTp_apDY0SgjEuGuPVdeUd9ovg at mail dot gmail dot com> <CAAkRFZL4fybLpf2shVqGcA5qQW+MveWfxcna5YpMJ8teeLPT2g at mail dot gmail dot com> <CA+4CFy74zAYFuf-A7utd9ZstieJQx7oR=V_Vjsf1FfxRXPe-dw at mail dot gmail dot com> <CAAkRFZKmqGMFRLgQeC=KhXYaEyyvtNfQDX4EuyhiyV4QqR0x3w at mail dot gmail dot com> <CA+4CFy6VePQSLDyZsJVtYXzG=nZ1-RH4grgoXQaUedRMeocVow at mail dot gmail dot com>
ok for google branch for now. Please resubmit to trunk and backport
the trunk version if needed.
thanks,
David
On Tue, Feb 11, 2014 at 10:29 AM, Wei Mi <wmi@google.com> wrote:
>>> +/* Return true if the use is defined by a gcov counter var.
>>> + It is used to check if an iv candidate is generated for
>>> + profiling. For profile generated ssa name, we should not
>>> + use it as IV because gcov counter may have data-race for
>>> + multithread program, it could involve tricky bug to use
>>> + such ssa var in IVOPT.
>>> +
>>
>> Add the snippets describing how ralloc introduces a second gcov
>> counter load and asynchronous update of it from another thread leading
>> to bogus trip count.
>>
>> Also mention that setting volatile flag on gcov counter accesses may
>> greatly degrade profile-gen performance.
>>
>
> Comments added.
>
>>> + if (!is_gimple_assign (stmt))
>>> + return false;
>>> +
>>> + rhs = gimple_assign_rhs1 (stmt);
>>> + if (TREE_CODE (rhs) != ARRAY_REF)
>>> + return false;
>>> +
>>> + decl = TREE_OPERAND (rhs, 0);
>>> + if (TREE_CODE (decl) != VAR_DECL)
>>> + return false;
>>
>>
>>
>> Also check TREE_STATIC and DECL_ARTIFICIAL flag.
>>
>>
>> David
>>
>
> Check added. Add DECL_ARTIFICIAL setting in build_var() in coverage.c.
>
> The updated patch is attached.
>
> Thanks,
> Wei.