From patchwork Sun Mar 17 12:04:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1057496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-498006-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ts+LSrYp"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="dyVOI7g2"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44MdKF4Dfmz9sD4 for ; Sun, 17 Mar 2019 23:04:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Ptr3iPGXXG34XvNRmuCInMT/xsZWpTR5gRe5ftGO4/KMzYEcOi 7XWeh7J4aiKcsSVcSRAeDBspMeBZE6OZKynwJc4Z/C+fY/Gr0vriNlEOX/aI/KQ/ OOiTiG4qtIVALFttbh2eohbGCu7qyfjMmgZ2J1q+EXxQQrU2qJDU9c5pI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=uVqameDiYMedmiIVW6MeB4i+p/A=; b=Ts+LSrYpwT5qmml97PWh PtZ/q6V0WZ11WEg3imxjJYUr1Sdw0UDROcMil6wuVtZTYrh/VTkG9JVhlWju0TMY 7JXUCN7j71f0L8Rvt8hR0+8c5AXw5DRd0cyQU8wjTf7P6jBA46CTKcsqr8Ira+OB ArJRk//LpgyEjZ5owq0nLwk= Received: (qmail 73600 invoked by alias); 17 Mar 2019 12:04:22 -0000 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 Received: (qmail 73571 invoked by uid 89); 17 Mar 2019 12:04:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:gfc_res, backend_decl X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Mar 2019 12:04:20 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 0F8A3131DD; Sun, 17 Mar 2019 13:04:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1552824256; bh=C//mGW+jF2IFc8+UXmiagteapWRUP2SkpAf0oYIF4Uo=; h=To:From:Subject:Message-ID:Date:From; b=dyVOI7g2+5k1jAW6pfS3LD2bN2dmKrg6hH/ObgPMN1lKwt3ZvVk8HywVvq9LrWjjz 0meR/XI9NpZT6GBPtYV1zBjFRL9voExSwG46oNTVatEeIpALSU6E5QXZEadb0LR6at aJxa+1WxrbhxeMyjSsK/nTzgHzkofEzGSvr6Z/Aa00dnOj/E+FxzYk7FOKCFKPI7W1 DuPdbDvgF4SBwFS5AsMr+g0cQp/xUAcoFMDwXIW/fhy4K4qBH/Sa5WiL3PocrTelvr nCYiT1xG7291QjCSQESFZd1GAh1Di7DC1AQGixSIiEOPBbFIAFtw1lLbbsJmfoG6pX vgXM0L4pwc9vg== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 0A99E11E73; Sun, 17 Mar 2019 13:04:16 +0100 (CET) Received: from [2001:4dd6:3e3:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c8e37c0-0bea-7f0000012729-7f000001c7f8-1 for ; Sun, 17 Mar 2019 13:04:16 +0100 Received: from [IPv6:2001:4dd6:3e3:0:7285:c2ff:fe6c:992d] (2001-4dd6-3e3-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd6:3e3:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 17 Mar 2019 13:04:14 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 68009, wrong prototype in runtime_error Message-ID: <92672f08-a2f6-f45b-334f-f7650aa78e56@netcologne.de> Date: Sun, 17 Mar 2019 13:04:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Hello world, this fixes a 7/8/9 regression. The problem is that front-end inlining of matmul could generate calls to _gfortran_runtime_error which were called as non-variadic. This fixes the problem by setting the backend_decl on the resovled symbol, so it always uses the right one. Putting it into the resolution stage seems a bit strange, but I tried several other methods such as putting it into the global symbol table, and nothing else I tried worked. You can check on x86_64 if the patch works by doing $ cat nn.f90 module x contains subroutine mm(a,b,c) real, dimension(:) :: a, c real, dimension(:,:) :: b c = matmul(a,b) end subroutine mm end module x $ gfortran -S -O -fcheck=bounds nn.f90 and then looking for code snippets like movl $89, %ecx movq %rdi, %rdx movl $.LC0, %edi movl $0, %eax call _gfortran_runtime_error where setting %eax to zero indicates that we are indeed using varargs, because %eax contains the number of float arguments, which is zero. No test case, because there is not really a good way to check for this. So, OK for trunk? Regards Thomas 2019-03-17 Thomas Koenig PR fortran/68009 * iresolve.c: Include trans.h. (gfc_resolve_fe_runtine_error): Set backend_decl on resolved_sym. Tested-by: Thomas Schwinge Index: iresolve.c =================================================================== --- iresolve.c (Revision 269624) +++ iresolve.c (Arbeitskopie) @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "intrinsic.h" #include "constructor.h" #include "arith.h" +#include "trans.h" /* Given printf-like arguments, return a stable version of the result string. @@ -2495,6 +2496,10 @@ gfc_resolve_fe_runtime_error (gfc_code *c) a->name = "%VAL"; c->resolved_sym = gfc_get_intrinsic_sub_symbol (name); + /* We set the backend_decl here because runtime_error is a + variadic function and we would use the wrong calling + convention otherwise. */ + c->resolved_sym->backend_decl = gfor_fndecl_runtime_error; } void