From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id B60793858004; Sat, 3 Apr 2021 20:28:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B60793858004 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-7974] Darwin : Fix out-of-bounds access to df_regs_ever_live. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: ad7c6298b6f1cf4eaa70a53af3479fab14018896 X-Git-Newrev: 89bc1d4e7cdd0b2d012050134ad1d464ec357f0b Message-Id: <20210403202858.B60793858004@sourceware.org> Date: Sat, 3 Apr 2021 20:28:58 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2021 20:28:58 -0000 https://gcc.gnu.org/g:89bc1d4e7cdd0b2d012050134ad1d464ec357f0b commit r11-7974-g89bc1d4e7cdd0b2d012050134ad1d464ec357f0b Author: Iain Sandoe Date: Sat Apr 3 10:07:48 2021 +0100 Darwin : Fix out-of-bounds access to df_regs_ever_live. During changes made for LRA (or, perhaps, even before) we omitted a check that the current register we are working on is a hard reg before we tried to note its liveness. A stage 1 built with fsanitize=address catches this, as does any attempt to build master with clang and -std=c++11. gcc/ChangeLog: * config/darwin.c (machopic_legitimize_pic_address): Check that the current pic register is one of the hard reg set before setting liveness. Diff: --- gcc/config/darwin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index c1086a04700..5d173919ee0 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -907,7 +907,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) pic = reg; } - if (lra_in_progress) + if (lra_in_progress && HARD_REGISTER_P (pic)) df_set_regs_ever_live (REGNO (pic), true); pic_ref = gen_rtx_PLUS (Pmode, pic, machopic_gen_offset (XEXP (orig, 0))); @@ -974,7 +974,8 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) emit_move_insn (reg, pic); pic = reg; } - if (lra_in_progress) + + if (lra_in_progress && HARD_REGISTER_P (pic)) df_set_regs_ever_live (REGNO (pic), true); pic_ref = gen_rtx_PLUS (Pmode, pic,