From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30786 invoked by alias); 4 Dec 2014 09:24:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30741 invoked by uid 48); 4 Dec 2014 09:24:09 -0000 From: "amylaar at gcc dot 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: Thu, 04 Dec 2014 09:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amylaar at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: amylaar at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg00440.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64003 --- Comment #13 from Jorn Wolfgang Rennecke --- (In reply to David Malcolm from comment #6) > 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? insn_min_length is not supposed to use current insn lengths. genattrtab does not follow attributes for the purposes of determining insn current length dependence. So far we consider it the job of the port to provide a length attribute that allows the calculation of minimum/maximum instruction lengths with this limitation in mind. That means the length attribute in i386.md is broken. The get_attr_length_nobnd attribute need to be either inlined, or its use guarded in a clause that appears to be length depepdent and supplies minimum and maximum values. AFAICS, the length attribute was broken in r217125 https://gcc.gnu.org/ml/gcc-cvs/2014-11/msg00133.html