From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6023 invoked by alias); 23 Oct 2008 22:59:06 -0000 Received: (qmail 6015 invoked by uid 22791); 23 Oct 2008 22:59:05 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 23 Oct 2008 22:58:29 +0000 Received: from spaceape14.eur.corp.google.com (spaceape14.eur.corp.google.com [172.28.16.148]) by smtp-out.google.com with ESMTP id m9NMwLVk019556 for ; Thu, 23 Oct 2008 23:58:22 +0100 Received: from rv-out-0708.google.com (rvbk29.prod.google.com [10.140.87.29]) by spaceape14.eur.corp.google.com with ESMTP id m9NMwIgR028741 for ; Thu, 23 Oct 2008 15:58:20 -0700 Received: by rv-out-0708.google.com with SMTP id k29so754015rvb.30 for ; Thu, 23 Oct 2008 15:58:18 -0700 (PDT) Received: by 10.140.178.10 with SMTP id a10mr5746727rvf.2.1224802698656; Thu, 23 Oct 2008 15:58:18 -0700 (PDT) Received: by 10.140.166.5 with HTTP; Thu, 23 Oct 2008 15:58:18 -0700 (PDT) Message-ID: Date: Fri, 24 Oct 2008 06:17:00 -0000 From: "Cary Coutant" To: gcc-patches@gcc.gnu.org Subject: [lto][patch] Fix internal compiler error in stabilize_va_list MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg01013.txt.bz2 The following patch fixes an ICE in stabilize_va_list, when the type of the va_list parameter does not match the builtin va_list_type_node. The problem occurs only on x86_64, where the builtin va_list type is an array type instead of a simple type, and where the parameter has a pointer type to the underlying type. When building the list of preloaded common nodes in lto_get_common_nodes, we were recording only the top-level type nodes, so the underlying type was not recognized as a common type, and was streamed out and reconstructed by the reader. As a result, the type was not recognized as the builtin type in stabilize_va_list. This patch fixes the problem by checking specifically for an array type in lto_record_common_node, and records the underlying type node as well. There's an existing FIXME in lto_record_common_node: /* FIXME lto: In principle, we should perform a walk over all nodes reachable from each preloaded node. This is going to be a lot of work. At present, we catch the case that was causing test failures. A small step. */ It may be about time to take a longer look at this, but this patch takes just one more small step. I've boiled this down to the simple test case included below, but I'm not sure yet where to put LTO tests. OK? -cary ------- valist.c ------- #include #include int myprintf(const char *fmt, ...) { int n; va_list args; va_start(args,fmt); n = vprintf(fmt, args); va_end(args); return n; } int main() { int n; n = myprintf("%s: %d\n", "foo", 1); return 0; } ------- 2008-10-23 Cary Coutant * lto-section-out.c (lto_record_common_node): For array types, record the underlying type. Index: lto-section-out.c =================================================================== --- lto-section-out.c (revision 141329) +++ lto-section-out.c (working copy) @@ -877,6 +877,10 @@ lto_record_common_node (tree node, VEC(t lto_record_common_node (TYPE_MAIN_VARIANT (node), common_nodes, seen_nodes); } + if (TREE_CODE (node) == ARRAY_TYPE) + { + lto_record_common_node (TREE_TYPE (node), common_nodes, seen_nodes); + } } }