From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26554 invoked by alias); 24 Jan 2003 21:20:55 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26485 invoked from network); 24 Jan 2003 21:20:54 -0000 Received: from unknown (HELO mx2.redhat.com) (12.150.115.133) by 172.16.49.205 with SMTP; 24 Jan 2003 21:20:54 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.11.6/8.11.6) with ESMTP id h0OLFO104544; Fri, 24 Jan 2003 16:15:24 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h0OLKon26729; Fri, 24 Jan 2003 16:20:50 -0500 Received: from localhost.localdomain (frothingslosh.sfbay.redhat.com [172.16.24.27]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id h0OLKoE15106; Fri, 24 Jan 2003 13:20:50 -0800 Received: (from rth@localhost) by localhost.localdomain (8.11.6/8.11.6) id h0OLKlI28119; Fri, 24 Jan 2003 13:20:47 -0800 X-Authentication-Warning: localhost.localdomain: rth set sender to rth@redhat.com using -f Date: Fri, 24 Jan 2003 21:42:00 -0000 From: Richard Henderson To: Janis Johnson Cc: gcc@gcc.gnu.org, rodrigc@attbi.com, bangerth@ticam.utexas.edu Subject: Re: patch that caused regression PR optimization/4382 Message-ID: <20030124212047.GD25074@redhat.com> Mail-Followup-To: Richard Henderson , Janis Johnson , gcc@gcc.gnu.org, rodrigc@attbi.com, bangerth@ticam.utexas.edu References: <20021219152513.A30891@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021219152513.A30891@us.ibm.com> User-Agent: Mutt/1.4i X-SW-Source: 2003-01/txt/msg01176.txt.bz2 On Thu, Dec 19, 2002 at 03:25:13PM -0800, Janis Johnson wrote: > The regression reported in PR optimization/4382 showed up ... This is _really_ borderline, but ok. We'll hack around this problem like so. If you call both __builtin_setjmp and __builtin_longjmp in the same function, expect things to crash again, however. All I can say is, Don't Do That. r~ * tree-inline.c (find_builtin_longjmp_call_1): New. (find_builtin_longjmp_call): New. (inlinable_function_p): Use it. Index: tree-inline.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v retrieving revision 1.40 diff -c -p -d -r1.40 tree-inline.c *** tree-inline.c 24 Dec 2002 08:30:33 -0000 1.40 --- tree-inline.c 24 Jan 2003 21:14:47 -0000 *************** static tree add_stmt_to_compound PARAMS *** 125,130 **** --- 125,132 ---- #endif /* INLINER_FOR_JAVA */ static tree find_alloca_call_1 PARAMS ((tree *, int *, void *)); static tree find_alloca_call PARAMS ((tree)); + static tree find_builtin_longjmp_call_1 PARAMS ((tree *, int *, void *)); + static tree find_builtin_longjmp_call PARAMS ((tree)); /* The approximate number of instructions per statement. This number need not be particularly accurate; it is used only to make *************** tree_inlinable_function_p (fn) *** 873,879 **** return inlinable_function_p (fn, NULL); } ! /* if *TP is possibly call to alloca, return nonzero. */ static tree find_alloca_call_1 (tp, walk_subtrees, data) tree *tp; --- 875,881 ---- return inlinable_function_p (fn, NULL); } ! /* If *TP is possibly call to alloca, return nonzero. */ static tree find_alloca_call_1 (tp, walk_subtrees, data) tree *tp; *************** find_alloca_call_1 (tp, walk_subtrees, d *** 885,892 **** return NULL; } ! /* Return subexpression representing possible alloca call, ! if any. */ static tree find_alloca_call (exp) tree exp; --- 887,893 ---- return NULL; } ! /* Return subexpression representing possible alloca call, if any. */ static tree find_alloca_call (exp) tree exp; *************** find_alloca_call (exp) *** 894,899 **** --- 895,926 ---- return walk_tree (&exp, find_alloca_call_1, NULL, NULL); } + static tree + find_builtin_longjmp_call_1 (tp, walk_subtrees, data) + tree *tp; + int *walk_subtrees ATTRIBUTE_UNUSED; + void *data ATTRIBUTE_UNUSED; + { + tree exp = *tp, decl; + + if (TREE_CODE (exp) == CALL_EXPR + && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR + && (decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0), + TREE_CODE (decl) == FUNCTION_DECL) + && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (decl) == BUILT_IN_LONGJMP) + return decl; + + return NULL; + } + + static tree + find_builtin_longjmp_call (exp) + tree exp; + { + return walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL); + } + /* Returns nonzero if FN is a function that can be inlined into the inlining context ID_. If ID_ is NULL, check whether the function can be inlined at all. */ *************** inlinable_function_p (fn, id) *** 933,938 **** --- 960,973 ---- allowance for extern inline functions, though. */ else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn) && currfn_insns > MAX_INLINE_INSNS_SINGLE) + ; + /* We can't inline functions that call __builtin_longjmp at all. + The non-local goto machenery really requires the destination + be in a different function. If we allow the function calling + __builtin_longjmp to be inlined into the function calling + __builtin_setjmp, Things will Go Awry. */ + /* ??? Need front end help to identify "regular" non-local goto. */ + else if (find_builtin_longjmp_call (DECL_SAVED_TREE (fn))) ; /* Refuse to inline alloca call unless user explicitly forced so as this may change program's memory overhead drastically when the function using alloca