From patchwork Sat Oct 13 17:32:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 983601 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-487502-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Hs2ODU78"; 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 42XWxl1YxMz9s47 for ; Sun, 14 Oct 2018 04:32:55 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=a7Mhr/KGp+eT6zDW 7qj6hvnKNYqm0g1WL8Lvi97RsPN6SoMk92HbhJwMBupfNzij2tzMurVLGAGZR3/R OytrUWdZOTWESxajtzUTVprhqhECC4OiBt4fzsDuv466x+XL1Oj+rnQ3vwq5yPVu zgX+C+r4BZjMFOzaZr11dGzpiOA= 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 :content-transfer-encoding; s=default; bh=g/jERZ3yc2wlPF+NJjEkbT 4JVvg=; b=Hs2ODU78WqdhqEEqkVhfHY57hK1+rrRD1ui9cdY2sVW7OojjIjTtsh FnAAWCam6GENG68tiFuLbf/EuJ97xKDozPZHhXrP8MRboaJkvVL+wrQz+BX3Fxcp ue9VRDH2tx6VAmQcGkAzhH9UjdAoT9azsv6KJKK1uwE0AvUHVkUpc= Received: (qmail 82364 invoked by alias); 13 Oct 2018 17:32:48 -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 82351 invoked by uid 89); 13 Oct 2018 17:32:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 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=reducing, Search, dwarf2cfi.c, UD:dwarf2cfi.c X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 13 Oct 2018 17:32:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E01B781395 for ; Sat, 13 Oct 2018 19:32:43 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sSsREt61MgQ8 for ; Sat, 13 Oct 2018 19:32:43 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id BE4D38138F for ; Sat, 13 Oct 2018 19:32:43 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix ICE during RTL CFI generation pass Date: Sat, 13 Oct 2018 19:32:41 +0200 Message-ID: <1634069.gzBkOT923G@polaris> MIME-Version: 1.0 This fixes an assertion failure compiling the Ada Web Server package (soap/ soap-message-xml.adb to be precise) at -O2 -gnatn -fPIC on x86/Linux: +===========================GNAT BUG DETECTED==============================+ | Pro 20.0w (20181010-90) (i686-pc-linux-gnu) GCC error: | | in connect_traces, at dwarf2cfi.c:2825 | | Error detected around /byram.a/gnatmail/sandbox/gcc-head/x86-linux/ | | aws_bootstrap-gcc-head/src/src/soap/soap-message-xml.adb:914:8 | The ICE is extremely elusive and all my attempts at reducing the code failed. The assertion is meant to check that, if a trace contains an insn that can throw internally, then the incoming args_size values from preceding traces are all the same. That's not the case here because cross-jumping commonalized an insn restoring the stack pointer from the frame pointer, i.e setting args_size to 0, and redirected a jump to just before the insn. Now, before this insn, the args_size values need not match, for example if you have on one path a call whose post-call stack adjustments have not been emitted (because the stack pointer is restored just after in any case) and on another path a call whose post-call stack adjustments have been emitted as usual. So the attached patch relaxes the assertion by allowing the case where an insn sets the args_size in the current trace before the first insn that can throw internally. That's OK since DW_CFA_GNU_args_size notes are emitted only on this first insn or after it, and not at the start of the trace. Tested on x86/Linux and x86-64/Linux, applied on the mainline. 2018-10-13 Eric Botcazou * dwarf2cfi.c (struct dw_trace_info): Add args_size_defined_for_eh. (notice_args_size): Set it in the current trace if no insn that can throw internally has been seen yet. (connect_traces): When connecting args_size between traces, allow the incoming values not to match if there is an insn setting it before the first insn that can throw internally; in that case, force the creation of a CFI note on this latter insn. Index: dwarf2cfi.c =================================================================== --- dwarf2cfi.c (revision 264986) +++ dwarf2cfi.c (working copy) @@ -147,6 +147,9 @@ struct dw_trace_info /* True if we've seen different values incoming to beg_true_args_size. */ bool args_size_undefined; + + /* True if we've seen an insn with a REG_ARGS_SIZE note before EH_HEAD. */ + bool args_size_defined_for_eh; }; @@ -942,6 +945,9 @@ notice_args_size (rtx_insn *insn) if (note == NULL) return; + if (!cur_trace->eh_head) + cur_trace->args_size_defined_for_eh = true; + args_size = get_args_size (note); delta = args_size - cur_trace->end_true_args_size; if (known_eq (delta, 0)) @@ -2820,11 +2826,17 @@ connect_traces (void) if (ti->switch_sections) prev_args_size = 0; + if (ti->eh_head == NULL) continue; - gcc_assert (!ti->args_size_undefined); - if (maybe_ne (ti->beg_delay_args_size, prev_args_size)) + /* We require either the incoming args_size values to match or the + presence of an insn setting it before the first EH insn. */ + gcc_assert (!ti->args_size_undefined || ti->args_size_defined_for_eh); + + /* In the latter case, we force the creation of a CFI note. */ + if (ti->args_size_undefined + || maybe_ne (ti->beg_delay_args_size, prev_args_size)) { /* ??? Search back to previous CFI note. */ add_cfi_insn = PREV_INSN (ti->eh_head);