From patchwork Wed Mar 21 08:33:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 132193 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1863350ljb; Wed, 21 Mar 2018 01:33:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELvXfqQb4u0YJsntAikKImoKslyW5moeanwmbccFJzOrWXQbGsosCGb793gvpVtOvzGK1DbP X-Received: by 10.99.111.196 with SMTP id k187mr14141471pgc.360.1521621239533; Wed, 21 Mar 2018 01:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521621239; cv=none; d=google.com; s=arc-20160816; b=ntkrmoyaVyhU8BYhgB9d0dRXD02v1+8LTF7LvieVqvDW6PBf0xMxw+h6lj913PCYxy /7VWzlViOLUN7KODoPrlDx2znETU23+v+hSiLFVv6T2DZAA6p9g8jddIU3uI7DgeZuLI RQuSn2Tlpx2p/RrDse/OKYR8Ea9X/ArTLzl/X4hVZC6yfIlN4t6DPgyB6J5DNgsjc6jG JHRqzzWJhCCyAK4Jkh953OnFyLIsIVcBDECk+Y+Y5AGY4uXiF9+YWs7vJvdK7sEd4YVF E9Aeia83+fhv+sNvbL1G0DH0/f1A76XFtUVXw+YgGRooRTsK8Ea0jDkbzru6tIDNzlrd tVbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=fz0x7Cu7M+RvuQwGtSnonIomJI+71PwvZRXwl48y30k=; b=Ss8M9aqCBR4SE1J+43gp3Fr7kokj4EHC3q7qxyILAYb1kFvwIruOE4nVGRQmlu71yb nL0UObxpM5ZyaGPiaVIQpco+0/ew12flEm43poAZwyRH8j6TR7TXSO32dPttulYEKPfA OY5h1lgryaRDpVmfAiC59fkzw9gAp1diJzVICWboXA++XEWnlxHecWROLiEWbuAwXqOE EcpJsnRK4zLjiXUXdWZICJP4l8bAZzZhmTYKqJ/gGUXcXGLLxsed3yLDKTZu1lyDzxjZ tUBGCHtG3BsdYHqdqKqhhzZOe8Y5sfHURjLWIdk8rhTf2TprCwQ/6fFJeDJIklUMSm+9 nw7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yCks5iCH; spf=pass (google.com: domain of gcc-patches-return-475121-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-475121-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o24-v6si3743585pll.478.2018.03.21.01.33.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 01:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-475121-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yCks5iCH; spf=pass (google.com: domain of gcc-patches-return-475121-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-475121-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=ZOP6hJpvLP8V+1BwlGXWkbcIsVhvAX2KiM7WE9F6VFYgSl6h2Z+kC RLQnNczXGWk9xTsXBXwOSNArh3AebXxBO4x9BCiYpSlfdKX1fldkrQe6MpCoPZ1/ WA5jE+8fTqTA6IayfLOjKgn9cM1i7H66cSSc2lRYo4TZyFWIE332A4= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=TepRWyGlLm0JgTUkQl2xsgp1UOg=; b=yCks5iCHbSIUGCjqRTuB YnAf5xc7IG/SK4Oxh52cDTgPztJZTgloRHBJrjGg5OmHSa9bE5aMS0tsUC2h8ijt QOnEQGtS3VOy0KznWWyVr68l7ZRBze/f7whrbCVkM5YrG1sOjsvkP4zGqtPJq3Ux fHGi7hvx/DUuo7fE9DqkgOo= Received: (qmail 103047 invoked by alias); 21 Mar 2018 08:33:47 -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 102724 invoked by uid 89); 21 Mar 2018 08:33:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:preferr X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Mar 2018 08:33:45 +0000 Received: by mail-wm0-f67.google.com with SMTP id t6so8203704wmt.5 for ; Wed, 21 Mar 2018 01:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=fz0x7Cu7M+RvuQwGtSnonIomJI+71PwvZRXwl48y30k=; b=oj6P9q51m228QIJCLamDXGFap129sfK3ScuWUgsE67M/xAB+4loA0YVzYiPRg1tXne jHTOd231xUYxbEdyoVZjEo8fWUbSmb1Uc9atxhHN+0Q49SRWIW1zm2QjYb81xH7c9CBQ 0n9adLdh1Ej+6ITG30JE16y8yuIkHfM+GxvhfiKNRsKihpJ8nX9IYRz2DSbLWQ9EiSeO nb1nbM9d9AVl9tIwK6acrgfE66zFGE6RfmB6+gVdBemnLP2V6v18ramshrlmC/KwAOVx 0JJNpNs+guYVBwp3WM4pucBM15E7z4X1PMQ9NklcoNK1z//MEZwcdL1ph0lZR4lmExKE 9gvw== X-Gm-Message-State: AElRT7HjZr2T8VHcEBD7wSBOyxr4p0wvSj1OX+ge4uk5gif3CQjho0pS WY7jdOaP3xp4B0orygJeZSf0RbrSzsw= X-Received: by 10.28.136.74 with SMTP id k71mr1817914wmd.46.1521621222654; Wed, 21 Mar 2018 01:33:42 -0700 (PDT) Received: from localhost ([217.140.96.141]) by smtp.gmail.com with ESMTPSA id p14sm7317272wrc.30.2018.03.21.01.33.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 01:33:41 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Fix ICE after sorry for big stack arguments (PR 84964) Date: Wed, 21 Mar 2018 08:33:41 +0000 Message-ID: <871sgdzv2y.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 After the sorry we'd skip storing the argument, but that just creates an inconsistency later when we try to deallocate the arguments. This used to "work" because pending_stack_adjust and stack_pointer_delta were int rather than HWI, so 1<<33 got truncated to 0. It's not easy to back out at this point because there's so much global state floating around. One option I tried was to put the sorry after: unadjusted_args_size = compute_argument_block_size (reg_parm_stack_space, &adjusted_args_size, fndecl, fntype, (pass == 0 ? 0 : preferred_stack_boundary)); and then zero the argument sizes and num_actual. That avoids the ICE too, but who knows what other problems it creates. In the end it seemed easier just to stop. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2018-03-21 Richard Sandiford gcc/ PR error-recovery/84964 * diagnostic-core.h (fatal_sorry): Declare. * diagnostic.c (fatal_sorry): New function. * calls.c (expand_call): Use it instead of sorry. gcc/testsuite/ PR error-recovery/84964 * g++.dg/diagnostic/pr84964.C: New test. Index: gcc/diagnostic-core.h =================================================================== --- gcc/diagnostic-core.h 2018-03-01 08:20:43.590534306 +0000 +++ gcc/diagnostic-core.h 2018-03-21 08:31:34.635677798 +0000 @@ -87,6 +87,8 @@ extern bool permerror (location_t, const extern bool permerror (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); +extern void fatal_sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) + ATTRIBUTE_NORETURN; extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *, Index: gcc/diagnostic.c =================================================================== --- gcc/diagnostic.c 2018-03-01 08:20:43.589534337 +0000 +++ gcc/diagnostic.c 2018-03-21 08:31:34.635677798 +0000 @@ -1407,6 +1407,20 @@ sorry (const char *gmsgid, ...) va_end (ap); } +/* Same, but stop compilation immediately. */ + +void +fatal_sorry (const char *gmsgid, ...) +{ + va_list ap; + va_start (ap, gmsgid); + rich_location richloc (line_table, input_location); + diagnostic_impl (&richloc, -1, gmsgid, &ap, DK_SORRY); + va_end (ap); + + exit (FATAL_EXIT_CODE); +} + /* Return true if an error or a "sorry" has been seen. Various processing is disabled after errors. */ bool Index: gcc/calls.c =================================================================== --- gcc/calls.c 2018-03-17 08:30:20.937100705 +0000 +++ gcc/calls.c 2018-03-21 08:31:34.635677798 +0000 @@ -4052,13 +4052,10 @@ expand_call (tree exp, rtx target, int i rtx_insn *before_arg = get_last_insn (); /* We don't allow passing huge (> 2^30 B) arguments - by value. It would cause an overflow later on. */ + by value. It would cause an overflow later on. */ if (constant_lower_bound (adjusted_args_size.constant) >= (1 << (HOST_BITS_PER_INT - 2))) - { - sorry ("passing too large argument on stack"); - continue; - } + fatal_sorry ("passing too large argument on stack"); if (store_one_arg (&args[i], argblock, flags, adjusted_args_size.var != 0, Index: gcc/testsuite/g++.dg/diagnostic/pr84964.C =================================================================== --- /dev/null 2018-03-17 08:19:33.716019995 +0000 +++ gcc/testsuite/g++.dg/diagnostic/pr84964.C 2018-03-21 08:31:34.635677798 +0000 @@ -0,0 +1,6 @@ +/* { dg-do compile { target lp64 } } */ + +struct a { + short b : 1ULL << 33; /* { dg-warning "width of 'a::b' exceeds its type" } */ +}; +void c(...) { c(a()); } /* { dg-message "sorry, unimplemented: passing too large argument on stack" } */