From patchwork Fri Sep 3 14:29:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 63684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 35959B718B for ; Sat, 4 Sep 2010 00:29:56 +1000 (EST) Received: (qmail 26052 invoked by alias); 3 Sep 2010 14:29:46 -0000 Received: (qmail 26029 invoked by uid 22791); 3 Sep 2010 14:29:44 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL, BAYES_00, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Sep 2010 14:29:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 9479B8655F for ; Fri, 3 Sep 2010 16:29:36 +0200 (CEST) Date: Fri, 3 Sep 2010 16:29:36 +0200 (CEST) From: Michael Matz To: gcc-patches@gcc.gnu.org Subject: Fix PR45415: ICE in partition_view_bitmap Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, an oversight in early SRA missed to update a modified statement, leading to errors furtherdown, ultimately the ICE. To possibly catch such errors a bit earlier I've implemented some additional simple checks, in this case that the number of real SSA operands for an instruction matches the number of immediate def/use entries for that instruction (they have to match if update_stmt was run on the instruction). Regstrapped on x86_64-linux (all langs, but not Ada this time). Okay for trunk? Ciao, Michael. Index: tree-sra.c =================================================================== --- tree-sra.c (revision 163773) +++ tree-sra.c (working copy) @@ -2783,6 +2783,7 @@ sra_modify_assign (gimple *stmt, gimple_ true, GSI_SAME_STMT); if (gimple_assign_rhs1 (*stmt) != rhs) { + modify_this_stmt = true; gimple_assign_set_rhs_from_tree (&orig_gsi, rhs); gcc_assert (*stmt == gsi_stmt (orig_gsi)); } Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 163773) +++ tree-ssa.c (working copy) @@ -938,6 +938,8 @@ verify_ssa (bool check_modified_stmt) gimple stmt = gsi_stmt (gsi); use_operand_p use_p; bool has_err; + int count; + unsigned i; if (check_modified_stmt && gimple_modified_p (stmt)) { @@ -1007,6 +1009,7 @@ verify_ssa (bool check_modified_stmt) goto err; } + count = 0; FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE|SSA_OP_DEF) { if (verify_ssa_name (op, false)) @@ -1014,6 +1017,19 @@ verify_ssa (bool check_modified_stmt) error ("in statement"); print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS); goto err; + } + count++; + } + + for (i = 0; i < gimple_num_ops (stmt); i++) + { + op = gimple_op (stmt, i); + if (op && TREE_CODE (op) == SSA_NAME && --count < 0) + { + error ("nr of operands and imm-links doesn't agree"); + error ("in statement"); + print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS); + goto err; } } Index: testsuite/gcc.dg/pr45415.c =================================================================== --- testsuite/gcc.dg/pr45415.c (revision 0) +++ testsuite/gcc.dg/pr45415.c (revision 0) @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dominator-opts" } */ + +typedef unsigned long int st; +typedef unsigned long long dt; +typedef union +{ + dt d; + struct + { + st h, l; + } + s; +} t_be; + +typedef union +{ + dt d; + struct + { + st l, h; + } + s; +} t_le; + +#define df(f, t) \ +int \ +f (t afh, t bfh) \ +{ \ + t hh; \ + t hp, lp, dp, m; \ + st ad, bd; \ + int s; \ + s = 0; \ + ad = afh.s.h - afh.s.l; \ + bd = bfh.s.l - bfh.s.h; \ + if (bd > bfh.s.l) \ + { \ + bd = -bd; \ + s = ~s; \ + } \ + lp.d = (dt) afh.s.l * bfh.s.l; \ + hp.d = (dt) afh.s.h * bfh.s.h; \ + dp.d = (dt) ad *bd; \ + dp.d ^= s; \ + hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \ + m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \ + return hh.s.l + m.s.l; \ +} + +df(f_le, t_le) +df(f_be, t_be) + +void abort (void); +void exit (int); +main () +{ + t_be x; + x.s.h = 0x10000000U; + x.s.l = 0xe0000000U; + if (x.d == 0x10000000e0000000ULL + && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1) + abort (); + if (x.d == 0xe000000010000000ULL + && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1) + abort (); + exit (0); +}