public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64003] valgrind complains about get_attr_length_nobnd in insn-attrtab.c from i386.md
Date: Fri, 21 Nov 2014 19:04:00 -0000	[thread overview]
Message-ID: <bug-64003-4-pcBDFMteuC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64003-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64003

--- Comment #6 from dmalcolm at gcc dot gnu.org ---
If I'm reading things right, this loop in shorten_branches populates
insn_lengths[uid] in order of the NEXT_INSN () iteration:

  int (*length_fun) (rtx_insn *) = increasing ? insn_min_length :
insn_default_length;

  for (insn_current_address = 0, insn = first;
       insn != 0;
       insn_current_address += insn_lengths[uid], insn = NEXT_INSN (insn))
    {
      uid = INSN_UID (insn);

      insn_lengths[uid] = 0;

      /* lots of logic, which can call length_fun, and hence insn_min_length. 
*/
    }

and "length_fun" can call into insn_min_length, and hence this calls into the
get_attr_length_nobnd, which AIUI for this case is accessing lengths of other
insns before they've been populated: presumably for a jump forwards?


FWIW this untested patch silences the valgrind warning:

diff --git a/gcc/final.c b/gcc/final.c
index c3805c9..0805418 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -1019,7 +1019,7 @@ shorten_branches (rtx_insn *first)
     return;

   /* Allocate the rest of the arrays.  */
-  insn_lengths = XNEWVEC (int, max_uid);
+  insn_lengths = XCNEWVEC (int, max_uid);
   insn_lengths_max_uid = max_uid;
   /* Syntax errors can lead to labels being outside of the main insn stream.
      Initialize insn_addresses, so that we get reproducible results.  */
@@ -1127,8 +1127,6 @@ shorten_branches (rtx_insn *first)
     {
       uid = INSN_UID (insn);

-      insn_lengths[uid] = 0;
-
       if (LABEL_P (insn))
        {
          int log = LABEL_TO_ALIGNMENT (insn);


  parent reply	other threads:[~2014-11-21 19:04 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 18:39 [Bug rtl-optimization/64003] New: " dmalcolm at gcc dot gnu.org
2014-11-20 18:41 ` [Bug rtl-optimization/64003] " dmalcolm at gcc dot gnu.org
2014-11-20 18:54 ` dmalcolm at gcc dot gnu.org
2014-11-20 19:23 ` dmalcolm at gcc dot gnu.org
2014-11-20 19:27 ` dmalcolm at gcc dot gnu.org
2014-11-20 19:41 ` dmalcolm at gcc dot gnu.org
2014-11-21 19:04 ` dmalcolm at gcc dot gnu.org [this message]
2014-12-02  2:20 ` [Bug target/64003] " dmalcolm at gcc dot gnu.org
2014-12-02 15:40 ` dmalcolm at gcc dot gnu.org
2014-12-02 15:48 ` dmalcolm at gcc dot gnu.org
2014-12-02 15:54 ` dmalcolm at gcc dot gnu.org
2014-12-02 16:08 ` dmalcolm at gcc dot gnu.org
2014-12-02 16:13 ` dmalcolm at gcc dot gnu.org
2014-12-04  9:24 ` amylaar at gcc dot gnu.org
2014-12-04 18:43 ` law at redhat dot com
2014-12-04 18:44 ` law at redhat dot com
2014-12-04 19:19 ` amylaar at gcc dot gnu.org
2014-12-04 19:38 ` enkovich.gnu at gmail dot com
2014-12-04 19:45 ` amylaar at gcc dot gnu.org
2014-12-04 19:51 ` law at redhat dot com
2014-12-04 19:54 ` law at redhat dot com
2014-12-05 10:07 ` enkovich.gnu at gmail dot com
2014-12-05 10:08 ` enkovich.gnu at gmail dot com
2014-12-05 10:38 ` ubizjak at gmail dot com
2014-12-05 10:50 ` ubizjak at gmail dot com
2014-12-05 14:19 ` rsandifo at gcc dot gnu.org
2014-12-05 15:01 ` enkovich.gnu at gmail dot com
2014-12-05 16:01 ` ienkovich at gcc dot gnu.org
2015-04-16 14:08 ` ienkovich at gcc dot gnu.org
2015-07-24  8:32 ` ubizjak at gmail dot com
2015-07-24  8:36 ` ubizjak at gmail dot com
2015-07-24 16:26 ` uros at gcc dot gnu.org
2015-07-24 16:31 ` ubizjak at gmail dot com

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=bug-64003-4-pcBDFMteuC@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).