From patchwork Wed Jan 9 10:11:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 210681 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 9482D2C008F for ; Wed, 9 Jan 2013 21:11:43 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1358331103; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=Ytnqh3NKc7tzhxZdsPIusV+DII8=; b=AUJf/abRuXty4V6 AFHB7kIIG0/hqXANzhgltg/vgH2G9FQlLXauqJnRVGWJIWfVJ1T6J7ZoKfUQkJjy gLkfx1tx3ZneGNOkosDAOuUgtlGS/ENPj4SMge/b/tkoZSudRXD8u9UhCFEeBn11 jY/6IxwtXwoIiVxvpJcq13/QXoGA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Nf1ewIqeeiYszDqmJXJeFAsYuh94fic800FnIA37LFuGiHX4ISQT53pPRwtyuS p3nq6qFkKjcz+E8QDhPB5o0KV45M2al0hlFaucgvQXJFDCQRI0G30qF+xcBe0Zem 6lR7g8nxEy5+uSsfMrTP8W/Ej9JW6F8ak4GLZPQoys6jA=; Received: (qmail 29956 invoked by alias); 9 Jan 2013 10:11:33 -0000 Received: (qmail 29936 invoked by uid 22791); 9 Jan 2013 10:11:29 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, TW_EG, TW_FN X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Jan 2013 10:11:21 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Tsscx-0005G7-VK from Tom_deVries@mentor.com ; Wed, 09 Jan 2013 02:11:19 -0800 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 9 Jan 2013 02:11:19 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.1.289.1; Wed, 9 Jan 2013 10:11:17 +0000 Message-ID: <50ED4241.4010904@mentor.com> Date: Wed, 9 Jan 2013 11:11:13 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Richard Biener CC: Jakub Jelinek , "gcc-patches@gcc.gnu.org" Subject: [PATCH] Yet another non-prototype builtin issue (PR middle-end/55890) 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 Richard, I've build r195008 for target mips64-linux-gnu with low optimization level ({CFLAGS,CXXFLAGS,BOOT_CFLAGS}='-g -O0'), and noticed failures for gcc.dg/torture/pr55890-{1,2,3}.c at -O0 and -O1 (which are not there without the low optimization level). The -O1 pr55890-1.c failure looks like this: ... $ mips64-linux-gnu-gcc gcc/testsuite/gcc.dg/torture/pr55890-1.c -fno-diagnostics-show-caret -O1 -S -o pr55890-1.s gcc/testsuite/gcc.dg/torture/pr55890-1.c: In function 'main': gcc/testsuite/gcc.dg/torture/pr55890-1.c:6:11: internal compiler error: Segmentation fault 0x86dad80 crash_signal gcc/toplev.c:334 0x82bec14 expand_call(tree_node*, rtx_def*, int) gcc/calls.c:3139 0x82adae3 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int) gcc-mainline/gcc/builtins.c:6866 0x83d5484 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**) gcc-mainline/gcc/expr.c:10141 0x82d7721 expand_call_stmt gcc-mainline/gcc/cfgexpand.c:2115 0x82d77eb expand_gimple_stmt_1 gcc/cfgexpand.c:2153 0x82d7e51 expand_gimple_stmt gcc/cfgexpand.c:2305 0x82d8f76 expand_gimple_basic_block gcc/cfgexpand.c:4084 0x82d9d53 gimple_expand_cfg gcc/cfgexpand.c:4603 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. ... The segv occurs when evaluating GET_MODE (args[arg_nr].reg) here: ... if (pass == 1 && (return_flags & ERF_RETURNS_ARG)) { int arg_nr = return_flags & ERF_RETURN_ARG_MASK; if (PUSH_ARGS_REVERSED) arg_nr = num_actuals - arg_nr - 1; if (args[arg_nr].reg && valreg && REG_P (valreg) && GET_MODE (args[arg_nr].reg) == GET_MODE (valreg)) call_fusage = gen_rtx_EXPR_LIST (TYPE_MODE (TREE_TYPE (args[arg_nr].tree_value)), gen_rtx_SET (VOIDmode, valreg, args[arg_nr].reg), call_fusage); } ... The expression (return_flags & ERF_RETURNS_ARG) is true because we're calculating return_flags using fndecl == memmove, and for memmove we're indeed returning the first arg. So arg_nr evaluates to 0, and we're accessing args[arg_nr].reg. But num_actuals is 0, so args is the result of alloca (0) and args[arg_nr] contains some random value, which causes the segv when evaluating GET_MODE (args[arg_nr].reg) (unless args[arg_nr].reg happens to be NULL, in which case we don't get there). Attached patch fixes this by testing whether arg_nr is in range before using it. Using the patch and a cc1 recompile, I'm able to run pr55890-{1,2,3}.c successfully. OK for trunk after I've tested this on mips64? Thanks, - Tom 2013-01-09 Tom de Vries PR middle-end/55890 * calls.c (expand_call): Check if arg_nr is valid. Index: gcc/calls.c =================================================================== --- gcc/calls.c (revision 195008) +++ gcc/calls.c (working copy) @@ -3136,7 +3136,9 @@ expand_call (tree exp, rtx target, int i int arg_nr = return_flags & ERF_RETURN_ARG_MASK; if (PUSH_ARGS_REVERSED) arg_nr = num_actuals - arg_nr - 1; - if (args[arg_nr].reg + if (arg_nr >= 0 + && arg_nr < num_actuals + && args[arg_nr].reg && valreg && REG_P (valreg) && GET_MODE (args[arg_nr].reg) == GET_MODE (valreg))