From patchwork Fri Oct 8 14:58:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 67228 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 49001B6F11 for ; Sat, 9 Oct 2010 01:58:16 +1100 (EST) Received: (qmail 586 invoked by alias); 8 Oct 2010 14:58:13 -0000 Received: (qmail 562 invoked by uid 22791); 8 Oct 2010 14:58:12 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL, BAYES_00, 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, 08 Oct 2010 14:58:07 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id C36BB4844E; Fri, 8 Oct 2010 16:58:04 +0200 (CEST) Date: Fri, 8 Oct 2010 16:58:04 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH] Fix the most annoying LTO -g ICE in dwarf2out.c Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 The most frequent bug I run into is PR45089 where LTO manages to not output a type that dwarf wants to reference via a AT_die_ref. This causes us to later crash in dwarf2out.c at the various places the target of the AT_die_ref is referenced. An easy workaround is to avoid generating this attribute in the first place if the target is NULL (and it's much easier than to try fixup the consumers). Bootstrapped and tested on x86_64-unknown-linux-gnu. This fixes all extra ICEs I get when building SPEC 2006 with -g in addition to -fwhopr -fwhole-program (this bug causes the build of 8 benchmarks to fail). Jason, does this sound like a reasonable workaround (yes, I'll be eventually looking for a way to avoid the situation in the first place, but it involves type-merging, a very fragile piece of code ...)? Thanks, Richard. 2010-10-08 Richard Guenther PR lto/45089 * dwarf2out.c (add_AT_die_ref): Work around LTO losing types. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 165169) +++ gcc/dwarf2out.c (working copy) @@ -7335,6 +7335,11 @@ add_AT_die_ref (dw_die_ref die, enum dwa { dw_attr_node attr; + /* With LTO we can end up trying to reference something we didn't create + a DIE for. Avoid crashing later on a NULL referenced DIE. */ + if (targ_die == NULL) + return; + attr.dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_die_ref; attr.dw_attr_val.v.val_die_ref.die = targ_die;