Exception at "need_ssa_update_p" during GIMPLE instrumentation

2020-06-21 Thread Shuai Wang via Gcc
Hello,

I am doing instrumentation of GIMPLE code by adding extra coverage counters
at each basic block. Basically it's mimicking -fsanitize-coverage=trace-pc,
where the only difference is that __sanitizer_cov_trace_pc (the default
hander of fsanitize-coverage=trace-pc)  has no input parameters, but my
coverage hander has a parameter of basic block id.

My current issue is that after the instrumentation of one function, the
plugin throws an exception at the following gcc_assert and do not proceed
to instrument another function:

  if (flags & TODO_cleanup_cfg)
cleanup_tree_cfg (flags & TODO_update_ssa_any);
  else if (flags & TODO_update_ssa_any)
update_ssa (flags & TODO_update_ssa_any);
  gcc_assert (!need_ssa_update_p (fn));  <--  line 1954 of
gcc/passes.c for gcc 10.1.0

This really confused me, because when I print out the instrumented
GIMPLE code and compare with fsanitize-coverage=trace-pc, I don't see
a major difference here:

== my instrumented GIMPLE code ===

fun2 ()
{
  int D.2588;
  int _3;

   :
  __sanitizer_cov_trace_pc (2);  <--- my coverage hander with basic
block id as the input
  __builtin_puts (&"fun2"[0]);
  _3 = 0;

   :
:
  __sanitizer_cov_trace_pc (3);
  return _3;

}

=== the corresponding instrumented GIMPLE code by
fsanitize-coverage=trace-pc =

fun2 ()
{
  int D.2760;
  int _3;

   [0.00%]:
  __builtin___sanitizer_cov_trace_pc ();
  __builtin_puts (&"fun2"[0]);
  _3 = 0;

 [0.00%]:
  __builtin___sanitizer_cov_trace_pc ();
  return _3;

}

There is no big difference here. Could anyone shed some lights on why
an exception on "need_ssa_update_p" is thrown? I don't think there is
an need to udpate any "SSA" here.. Thank you very much.

Best,

Shuai


Re: Exception at "need_ssa_update_p" during GIMPLE instrumentation

2020-06-21 Thread Shuai Wang via Gcc
OK, I think I know how to solve it. Just return TODO_update_ssa
.

On Sun, Jun 21, 2020 at 5:34 PM Shuai Wang  wrote:

> Hello,
>
> I am doing instrumentation of GIMPLE code by adding extra coverage
> counters at each basic block. Basically it's
> mimicking -fsanitize-coverage=trace-pc, where the only difference is
> that __sanitizer_cov_trace_pc (the default
> hander of fsanitize-coverage=trace-pc)  has no input parameters, but my
> coverage hander has a parameter of basic block id.
>
> My current issue is that after the instrumentation of one function, the
> plugin throws an exception at the following gcc_assert and do not proceed
> to instrument another function:
>
>   if (flags & TODO_cleanup_cfg)
> cleanup_tree_cfg (flags & TODO_update_ssa_any);
>   else if (flags & TODO_update_ssa_any)
> update_ssa (flags & TODO_update_ssa_any);
>   gcc_assert (!need_ssa_update_p (fn));  <--  line 1954 of 
> gcc/passes.c for gcc 10.1.0
>
> This really confused me, because when I print out the instrumented GIMPLE 
> code and compare with fsanitize-coverage=trace-pc, I don't see a major 
> difference here:
>
> == my instrumented GIMPLE code ===
>
> fun2 ()
> {
>   int D.2588;
>   int _3;
>
>:
>   __sanitizer_cov_trace_pc (2);  <--- my coverage hander with basic block id 
> as the input
>   __builtin_puts (&"fun2"[0]);
>   _3 = 0;
>
>:
> :
>   __sanitizer_cov_trace_pc (3);
>   return _3;
>
> }
>
> === the corresponding instrumented GIMPLE code by 
> fsanitize-coverage=trace-pc =
>
> fun2 ()
> {
>   int D.2760;
>   int _3;
>
>[0.00%]:
>   __builtin___sanitizer_cov_trace_pc ();
>   __builtin_puts (&"fun2"[0]);
>   _3 = 0;
>
>  [0.00%]:
>   __builtin___sanitizer_cov_trace_pc ();
>   return _3;
>
> }
>
> There is no big difference here. Could anyone shed some lights on why an 
> exception on "need_ssa_update_p" is thrown? I don't think there is an need to 
> udpate any "SSA" here.. Thank you very much.
>
> Best,
>
> Shuai
>
>


gcc-11-20200621 is now available

2020-06-21 Thread GCC Administrator via Gcc
Snapshot gcc-11-20200621 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/11-20200621/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 11 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch master 
revision 47ddb895df311e546a6f54345e18b8749ac50324

You'll find:

 gcc-11-20200621.tar.xz   Complete GCC

  SHA256=ac7566828cba717b23e0a954ac72dff9fa39cddbaa9beb03a3dedf72bccec75c
  SHA1=7d50c79e8deec024615c4a4cfee9f88740459ae6

Diffs from 11-20200614 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-11
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


Re: Exception at "need_ssa_update_p" during GIMPLE instrumentation

2020-06-21 Thread Richard Biener via Gcc
On June 21, 2020 11:38:49 AM GMT+02:00, Shuai Wang via Gcc  
wrote:
>OK, I think I know how to solve it. Just return TODO_update_ssa
>.

If you dump with -vops you'll likely see that virtual operands got out of sync. 
You can either manually copy them from the original function calls or as you 
do, make sure update_ssa runs. 

Richard. 

>On Sun, Jun 21, 2020 at 5:34 PM Shuai Wang 
>wrote:
>
>> Hello,
>>
>> I am doing instrumentation of GIMPLE code by adding extra coverage
>> counters at each basic block. Basically it's
>> mimicking -fsanitize-coverage=trace-pc, where the only difference is
>> that __sanitizer_cov_trace_pc (the default
>> hander of fsanitize-coverage=trace-pc)  has no input parameters, but
>my
>> coverage hander has a parameter of basic block id.
>>
>> My current issue is that after the instrumentation of one function,
>the
>> plugin throws an exception at the following gcc_assert and do not
>proceed
>> to instrument another function:
>>
>>   if (flags & TODO_cleanup_cfg)
>> cleanup_tree_cfg (flags & TODO_update_ssa_any);
>>   else if (flags & TODO_update_ssa_any)
>> update_ssa (flags & TODO_update_ssa_any);
>>   gcc_assert (!need_ssa_update_p (fn));  <--  line 1954 of
>gcc/passes.c for gcc 10.1.0
>>
>> This really confused me, because when I print out the instrumented
>GIMPLE code and compare with fsanitize-coverage=trace-pc, I don't see a
>major difference here:
>>
>> == my instrumented GIMPLE code ===
>>
>> fun2 ()
>> {
>>   int D.2588;
>>   int _3;
>>
>>:
>>   __sanitizer_cov_trace_pc (2);  <--- my coverage hander with basic
>block id as the input
>>   __builtin_puts (&"fun2"[0]);
>>   _3 = 0;
>>
>>:
>> :
>>   __sanitizer_cov_trace_pc (3);
>>   return _3;
>>
>> }
>>
>> === the corresponding instrumented GIMPLE code by
>fsanitize-coverage=trace-pc =
>>
>> fun2 ()
>> {
>>   int D.2760;
>>   int _3;
>>
>>[0.00%]:
>>   __builtin___sanitizer_cov_trace_pc ();
>>   __builtin_puts (&"fun2"[0]);
>>   _3 = 0;
>>
>>  [0.00%]:
>>   __builtin___sanitizer_cov_trace_pc ();
>>   return _3;
>>
>> }
>>
>> There is no big difference here. Could anyone shed some lights on why
>an exception on "need_ssa_update_p" is thrown? I don't think there is
>an need to udpate any "SSA" here.. Thank you very much.
>>
>> Best,
>>
>> Shuai
>>
>>