public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: GCC Development <gcc@gcc.gnu.org>
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: Help with rich_location and GIMPLE stmts
Date: Mon, 15 May 2017 13:36:00 -0000	[thread overview]
Message-ID: <6e53805a-8a02-1bdb-90e4-7ad1c292ec34@suse.cz> (raw)

Hi.

I sent this email to David some time ago, but it should be probably answered
on gcc mailing list.

I have idea one to improve gcov tool and I'm interested in more precise locations for gimple
statements. For gcov purpose, we dump location in ipa-profile pass, which is an early IPA
pass and this data is used by gcov tool to map statements (blocks) to lines of code.

I did a small experiment on the place we emit the location data:
		  inform (gimple_location (stmt), "output_location");

and it shows for:
$ cat m2.c
unsigned int
UuT (void)
{ unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }

int
main (int argc, char **argv)
{
  UuT ();
  return 0;
}

$ gcc --coverage m2.c
m2.c: In function ‘main’:
m2.c:8:3: note: output_location
   UuT ();
   ^~~~~~
# .MEM_2 = VDEF <.MEM_1(D)>
UuT ();
m2.c:9:10: note: output_location
   return 0;
          ^
_3 = 0;
m2.c: In function ‘UuT’:
m2.c:3:16: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                ^~~~~~~~
true_var_3 = 1;
m2.c:3:43: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                           ^~~~~~~~~
false_var_4 = 0;
m2.c:3:71: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                       ^~~
ret_5 = 0;
m2.c:3:83: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                                   ^
if (true_var_3 != 0)
m2.c:3:114: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                                                                  ^
if (false_var_4 != 0)
m2.c:3:145: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                                                                                             ~~~~^~~~~
ret_7 = 111;
m2.c:3:182: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                                                                                                                                  ~~~~^~~~~
ret_6 = 999;
m2.c:3:215: note: output_location
 { unsigned int true_var = 1; unsigned int false_var = 0; unsigned int ret = 0; if (true_var) /* count(1) */ { if (false_var) /* count(1) */ ret = 111; /* count(#####) */ } else ret = 999; /* count(#####) */ return ret; }
                                                                                                                                                                                                                       ^~~
_8 = ret_2;
m2.c:3:215: note: output_location
# VUSE <.MEM_9(D)>
return _8;

Which is not optimal, for some assignments I see just LHS (false_var_4 = 0), for return statements only a returned value is displayed. For conditions, only condition beginning is showed.
Is this known behavior or do I miss something?

Thanks,
Martin

             reply	other threads:[~2017-05-15 13:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 13:36 Martin Liška [this message]
2017-05-16 19:14 ` David Malcolm
2017-05-18 11:22   ` Martin Liška
2017-05-19 12:14     ` Marek Polacek
2017-05-19 14:30       ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e53805a-8a02-1bdb-90e4-7ad1c292ec34@suse.cz \
    --to=mliska@suse.cz \
    --cc=dmalcolm@redhat.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).