From patchwork Mon Feb 12 18:32:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 872282 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-473095-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cSqQfrmv"; 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 3zgDmw3WY4z9t3F for ; Tue, 13 Feb 2018 05:32:47 +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 :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=Vr6L6N0D9cceWCrnbUIJb53G9mZRlt5lR+4eJ1uxrklcDhHnkXehz ZdwiEs2Zk/15IAjd1M1I3J0oakrkJh4nxWV2k+GXBmT8xDtFvMGWCXT3Y84s8LQM 7rzfTNo7yH0L5UsYZmwIT+4eZsyonfk6woYOePIcahPjkowwF3j1fM= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=QRm4ZGWV1fJlOTWH47zMWb2u2Pg=; b=cSqQfrmvpx6h0kTuJGth DiGL21gToAFXpfI7CVZMj4M8Bj0mcGh0vKiW8V0v75DSXl0/63dTgbLexgWnlCVD NL6JwZiC9vRQ4kJ51J/W3ubb6mJgxi3AY/ukUhCfjxTDCDVfdblppYDpmgKwDDRF 1zLqgeLpzl7DHIZyz+z/aEQ= Received: (qmail 4449 invoked by alias); 12 Feb 2018 18:32:40 -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 4440 invoked by uid 89); 12 Feb 2018 18:32:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 18:32:39 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D93C861D0A for ; Mon, 12 Feb 2018 18:32:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-36.rdu2.redhat.com [10.10.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 178B160C4A for ; Mon, 12 Feb 2018 18:32:36 +0000 (UTC) From: Jeff Law Subject: [PATCH][committed] Fix ICE in maybe_record_trace_start To: gcc-patches Message-ID: Date: Mon, 12 Feb 2018 11:32:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-IsSubscribed: yes This was something my tester was tripping over on h8-elf. I was hoping it was going to fix the similar ICEs for the SH port, but alas those are different. The fundamental problem is generic code generated something like this: (set (temp) (plus (stack_pointer_rtx) (const_int)) (set (stack_pointer_rtx) (temp)) REG_ARGS_SIZE note The backward propagation step in cse.c turns the first insn into: (set (stack_pointer_rtx) (plus (stack_pointer_rtx) (const_int)) And the second insn gets deleted, losing the REG_ARGS_SIZE note. We then cross jump the tail of that block with the tail of another block which has REG_ARGS_SIZE notes that do not get deleted. The net result is at the commonized tail we have two paths which different notions of REG_ARGS_SIZE and thus different CFIs, triggering the ICE. The most sensible way to fix this is to move the REG_ARGS_SIZE note during the backward propagation step in cse.c That allows the H8 port to build libgcc/newlib across all its multilib variants. I've also bootstrapped and regression tested on x86_64-linux-gnu, though I doubt it really got exercised there. Installing on the trunk. Now back to the SH, rx and mips problems with maybe_record_trace_start. Jeff diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5a264391268..d5913d0a7db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-02-12 Jeff Law + + * cse.c (try_back_substitute_reg): Move any REG_ARGS_SIZE note when + successfully back substituting a reg. + 2018-02-12 Richard Biener PR tree-optimization/84037 diff --git a/gcc/cse.c b/gcc/cse.c index 825b0bd8989..a73a771041a 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -4256,6 +4256,15 @@ try_back_substitute_reg (rtx set, rtx_insn *insn) && (reg_mentioned_p (dest, XEXP (note, 0)) || rtx_equal_p (src, XEXP (note, 0)))) remove_note (insn, note); + + /* If INSN has a REG_ARGS_SIZE note, move it to PREV. */ + note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX); + if (note != 0) + { + remove_note (insn, note); + gcc_assert (!find_reg_note (prev, REG_ARGS_SIZE, NULL_RTX)); + set_unique_reg_note (prev, REG_ARGS_SIZE, XEXP (note, 0)); + } } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dba0bedb7cf..8f22a65c7bb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-02-12 Jeff Law + + * gcc.c-torture/compile/reg-args-size.c: New test. + 2018-02-12 Carl Love * gcc.target/powerpc/builtins-4-runnable.c (main): Move int128 and diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c new file mode 100644 index 00000000000..0ca0b9f034b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c @@ -0,0 +1,36 @@ +int foo; +typedef long unsigned int size_t; +typedef short unsigned int wchar_t; +struct tm +{ + int tm_mday; + int tm_mon; + int tm_year; +}; +size_t +__strftime (wchar_t * s, size_t maxsize, const wchar_t * format, const struct tm *tim_p) +{ + size_t count = 0; + int len = 0; + size_t i, ctloclen; + unsigned long width; + { + if (foo) + { + { + wchar_t *fmt = L"%s%.*d"; + len = swprintf (&s[count], maxsize, fmt, "-", width, 0); + } + if ((count) >= maxsize) + return 0; + } + else + { + len = + swprintf (&s[count], maxsize - count, L"%.2d/%.2d/%.2d", 42, 99, 0); + if ((count) >= maxsize) + return 0; + + } + } +}