From patchwork Tue Jul 26 19:52:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 106931 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 57B18B6F7B for ; Wed, 27 Jul 2011 05:52:34 +1000 (EST) Received: (qmail 30856 invoked by alias); 26 Jul 2011 19:52:32 -0000 Received: (qmail 30848 invoked by uid 22791); 26 Jul 2011 19:52:32 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Jul 2011 19:52:13 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6QJqD2U007362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Jul 2011 15:52:13 -0400 Received: from greed.delorie.com (ovpn-113-159.phx2.redhat.com [10.3.113.159]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6QJqCQg027728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 26 Jul 2011 15:52:12 -0400 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id p6QJqAFc007636 for ; Tue, 26 Jul 2011 15:52:10 -0400 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id p6QJqA8s007635; Tue, 26 Jul 2011 15:52:10 -0400 Date: Tue, 26 Jul 2011 15:52:10 -0400 Message-Id: <201107261952.p6QJqA8s007635@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: [patch] arm,rx: don't ICE on naked functions with local vars 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 This patch tests for at least one user-caused reason for this assertion failing - requiring a local frame in a naked function. For this case at least, it would be better to trigger an error than to ICE. OK? static int bar; void __attribute__((naked)) function(void) { int foo, result; result = subFunction(&foo, &bar); // ICE here } * expr.c (expand_expr_addr_expr_1): Detect a user request for a local frame in a naked function, and produce a suitable error for that specific case. Index: expr.c =================================================================== --- expr.c (revision 176766) +++ expr.c (working copy) @@ -6943,13 +6943,22 @@ expand_expr_addr_expr_1 (tree exp, rtx t modifier == EXPAND_INITIALIZER ? EXPAND_INITIALIZER : EXPAND_CONST_ADDRESS); /* If the DECL isn't in memory, then the DECL wasn't properly marked TREE_ADDRESSABLE, which will be either a front-end or a tree optimizer bug. */ - gcc_assert (MEM_P (result)); + + if (TREE_ADDRESSABLE (exp) + && ! MEM_P (result) + && ! targetm.calls.allocate_stack_slots_for_args()) + { + error ("local frame unavailable (naked function?)"); + return result; + } + else + gcc_assert (MEM_P (result)); result = XEXP (result, 0); /* ??? Is this needed anymore? */ if (DECL_P (exp) && !TREE_USED (exp) == 0) { assemble_external (exp);