From patchwork Fri Nov 24 16:33:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1868243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=YH80Schf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ScLCv40gHz1yRy for ; Sat, 25 Nov 2023 03:34:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19830385DC28 for ; Fri, 24 Nov 2023 16:34:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id EBA26385DC2F for ; Fri, 24 Nov 2023 16:34:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBA26385DC2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EBA26385DC2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700843645; cv=none; b=RD56tmhKQ2uNF4zwqjd/VMVxsQilyo07umi9D0uH15k1Vj8U2lgLcqIr2iAoUHtOleoO2s5R6mstR3YbKxxMC9AYs+3jwG7OP2ZCb655xMStzwPd7IHobs4lN+Cpe3IJbOzdWiFuPaA6ux8dsMS3x/5eijU2YIiI84mmH7kvmCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700843645; c=relaxed/simple; bh=YksgixsRjVrcr6WUWd/gV4kAv6fbHP9+4O/HWwPMcIw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=j+KXM+Rk7IjzRQcShshtsv6RTZnw5JgBKfgt1PuJVDvPc0PcsuefN6HoNY6Idw7Yqq3OtNHuNDwKNm2ZbO6NXBbqQnwey7JlL7IyWyDaiMmphJBJV0gDPFi/3mC/Aj1D4fTz9VQHr58/Xl95OxMJbOB9DIQ0IrwXeXUYA4z4U0A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-54b0310f536so1063670a12.0 for ; Fri, 24 Nov 2023 08:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700843642; x=1701448442; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=vgS5OuU/xXcmzHZR/3HO5r47F80xU3icFD6kRjzdqas=; b=YH80Schfepyd/U5PtJA0dHmCXx1MF4sMHCE+py7NFpYDgOV6ZxzKGNSQHe32yXAFjd hoVo443YzKn8fibs00w7n8jY60XXLwQMAUCrxFfBsnoO/ByI01ootlxREh/ZgPwllz/3 rMs2pxPT2EdOKgNZM2iNMfMHW9H9phW7/KnUmFlADuijilRE/YJIuQmInzISsdrwiof7 lxTAaXaS0YiQGeQpkF8cNbVLWfOYfsveWn2umTK/4KHZYRF25/fLsCCB+XD1ISXoenyS mN2fl9V1sPA1c5iCpR6UnvaUgh9LfB9SjerbLHS+koxvPaZZt0UnXqeNzuUtI6sBxCDx 3Upg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700843642; x=1701448442; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vgS5OuU/xXcmzHZR/3HO5r47F80xU3icFD6kRjzdqas=; b=j4qSWDqAky2G/fyf5wXyrY0BEGONVOS1VIWFplPFxrFTk9nGOdfxXPGBEpnwYEo/hN c5mzu7K3tXWjieOw2eBTZfFwMf7Ww4MeFRFCRMwH7+fCLPnPz57lWCdvgZjF50BfIcRe /cmeiFUvINykSDZMktqEpVivyN3XC7tYTlh4EtTn1kdwdOuzeoBGXaDL0ROPm07LHxcO LtHZpMCA0LrkhliyyMzJsA5E7u4oqWvFhE7ZwLfe2uT24HrVbmqFVHHZYY/NgXqHeDs1 CfdkXTX0+UdQ84C35NCxpB5oks2eYJemEk82je7Xcs6ej5jGvNXpxK1N30roMfI8+oLx 1Rxg== X-Gm-Message-State: AOJu0Yxjs7uhWj2Xv93qjmB43bN7Gb1X1ZOow003wPQeXCpvj9QAmsn7 5YcmcwVucuRclAfIiuqHCzOtmsLXTV/3Si8aj5YJPiHs7VHcGg== X-Google-Smtp-Source: AGHT+IFenZlLG8LLU+DpCynJ5wzWxEDWIXeYTr3l8uS/NLUcia26YMZ1VNaJ+EYOrJbCiHc7BDVXOooadNJjOmlPcio= X-Received: by 2002:aa7:d3c7:0:b0:54a:ff0f:78d6 with SMTP id o7-20020aa7d3c7000000b0054aff0f78d6mr1991534edr.0.1700843642295; Fri, 24 Nov 2023 08:34:02 -0800 (PST) MIME-Version: 1.0 From: Uros Bizjak Date: Fri, 24 Nov 2023 17:33:50 +0100 Message-ID: Subject: [committed] i386: Fix ICE with -fsplit-stack -mcmodel=large [PR112686] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org For -mcmodel=large, we have to load function address to a register. PR target/112686 gcc/ChangeLog: * config/i386/i386.cc (ix86_expand_split_stack_prologue): Load function address to a register for ix86_cmodel == CM_LARGE. gcc/testsuite/ChangeLog: * gcc.target/i386/pr112686.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 7b922857d80..9390f525b99 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -10481,6 +10481,8 @@ ix86_expand_split_stack_prologue (void) SYMBOL_REF_FLAGS (split_stack_fn_large) |= SYMBOL_FLAG_LOCAL; } + fn = split_stack_fn_large; + if (ix86_cmodel == CM_LARGE_PIC) { rtx_code_label *label; @@ -10494,16 +10496,15 @@ ix86_expand_split_stack_prologue (void) emit_insn (gen_set_rip_rex64 (reg10, label)); emit_insn (gen_set_got_offset_rex64 (reg11, label)); emit_insn (gen_add2_insn (reg10, reg11)); - x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, split_stack_fn_large), - UNSPEC_GOT); + x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fn), UNSPEC_GOT); x = gen_rtx_CONST (Pmode, x); emit_move_insn (reg11, x); x = gen_rtx_PLUS (Pmode, reg10, reg11); x = gen_const_mem (Pmode, x); fn = copy_to_suggested_reg (x, reg11, Pmode); } - else - fn = split_stack_fn_large; + else if (ix86_cmodel == CM_LARGE) + fn = copy_to_suggested_reg (fn, reg11, Pmode); /* When using the large model we need to load the address into a register, and we've run out of registers. So we diff --git a/gcc/testsuite/gcc.target/i386/pr112686.c b/gcc/testsuite/gcc.target/i386/pr112686.c new file mode 100644 index 00000000000..858e91ba727 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr112686.c @@ -0,0 +1,5 @@ +/* PR target/112686 */ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-fsplit-stack -mcmodel=large" } */ + +void foo (void) {}