From patchwork Sun Jul 12 06:27:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Hua X-Patchwork-Id: 1327455 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=A/jKXwsh; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4H070kt0z9sRK for ; Sun, 12 Jul 2020 16:28:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B467D385700E; Sun, 12 Jul 2020 06:27:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B467D385700E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594535278; bh=Pf8CxEXm6fxhrRglIROz9z0wf4HBftxz93FocJdfids=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=A/jKXwshGazsnOZahPXD6B+k/HVGP9BOmP6FVcGmGPnJTNUbHEU+OhJpdAUFICKxo VKvEcp3pCOTi47orCMmCspzQ0/OwCejRpXddVaYqhU8JA3jHkAD9B2IpoMJ/+zzTmj DlJ3whpPFa0wUhLlNLqq9jXnNYrgTKQqLEZsk2oI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by sourceware.org (Postfix) with ESMTPS id 402763857C7D for ; Sun, 12 Jul 2020 06:27:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 402763857C7D Received: by mail-io1-xd42.google.com with SMTP id q74so10287702iod.1 for ; Sat, 11 Jul 2020 23:27:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=Pf8CxEXm6fxhrRglIROz9z0wf4HBftxz93FocJdfids=; b=kMSiq441OQawX1P3ucWPIGaF6bDU/A1xFfgMqzx8AT1OJhrCMt4eBTRPF41NMWsH3Q vhLrqyGBcmxL5bfsYv2HLyILlaYvwOa97/IGvfzsT9wmeUp5BuAS7X4J+08WRKpfq6Sz CZ027mbdM4dabRGzZq2lBa/ECzE7uJQLDEfuR6UjjSjS0ETtHXEj6hiZAFF2w7nOU+1Q pZQxPR8r2AhxkYNc4ZBL1u6FOJfITKyxbh5Kx8XHTN9fcc6ai7slTgaZa5wN8YHzCiH5 JknO8eCQlOx4LnEeOj0Q/NToj1m8Od2e7HKt8EzsFp/gGBaBKD+OWVico20k+cftilG8 VdpQ== X-Gm-Message-State: AOAM532JI3qDLXJxlHYSmbaHMajzkMdmYnzo3NqjFRQqi085ua1yF3Jr hs9L4NH7rUGFldpj/uHlMAcbz6ZDOwH5+RBfzmiQMvYI X-Google-Smtp-Source: ABdhPJxadOTCG7D2bJWBCl8mU3zWweWjVLPl9TVwRTHotdjjUKC0sxGtSehq5J8AECRQ/juAjH6hFcOif0qvCvc8eFs= X-Received: by 2002:a5e:8f4b:: with SMTP id x11mr52561743iop.90.1594535275200; Sat, 11 Jul 2020 23:27:55 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 12 Jul 2020 14:27:43 +0800 Message-ID: Subject: [PATCH] MIPS: Fix __builtin_longjmp (PR 64242) To: gcc-patches X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Paul Hua via Gcc-patches From: Paul Hua Reply-To: Paul Hua Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From 589dbe8a1c2397bfafefa4e84abe5ec6e6798928 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Wed, 12 Feb 2020 11:42:57 +0000 Subject: [PATCH] MIPS: Fix __builtin_longjmp (PR 64242) The problem here is mips has its own builtin_longjmp pattern and it was not fixed when expand_builtin_longjmp was fixed. We need to read the new fp and gp before restoring the stack as the buffer might be a local variable. Change-Id: I3416568e260e6bde3ad5cc470fb4f2ecfa207f05 Signed-off-by: Andrew Pinski This patch from Andrew, I bootstrapped and tested on mips64el-linux-gnu. OK for master ? gcc/ChangeLog: PR middle-end/64242 * config/mips/mips.md (builtin_longjmp): Restore the frame pointer and stack pointer and gp. From 589dbe8a1c2397bfafefa4e84abe5ec6e6798928 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Wed, 12 Feb 2020 11:42:57 +0000 Subject: [PATCH] MIPS: Fix __builtin_longjmp (PR 64242) The problem here is mips has its own builtin_longjmp pattern and it was not fixed when expand_builtin_longjmp was fixed. We need to read the new fp and gp before restoring the stack as the buffer might be a local variable. Change-Id: I3416568e260e6bde3ad5cc470fb4f2ecfa207f05 Signed-off-by: Andrew Pinski --- gcc/config/mips/mips.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index dd9fdd1418d..8bafbe82bd3 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -6601,9 +6601,19 @@ /* This bit is similar to expand_builtin_longjmp except that it restores $gp as well. */ - mips_emit_move (hard_frame_pointer_rtx, fp); mips_emit_move (pv, lab); + /* Restore the frame pointer and stack pointer and gp. We must use a + temporary since the setjmp buffer may be a local. */ + fp = copy_to_reg (fp); + gpv = copy_to_reg (gpv); emit_stack_restore (SAVE_NONLOCAL, stack); + + /* Ensure the frame pointer move is not optimized. */ + emit_insn (gen_blockage ()); + emit_clobber (hard_frame_pointer_rtx); + emit_clobber (frame_pointer_rtx); + emit_clobber (gp); + mips_emit_move (hard_frame_pointer_rtx, fp); mips_emit_move (gp, gpv); emit_use (hard_frame_pointer_rtx); emit_use (stack_pointer_rtx); -- 2.17.1