From patchwork Sun Sep 10 14:10:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 137863 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1606310vqo; Sun, 10 Sep 2023 07:11:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbzAW25WbZHoc2WMQLFhRBXZ5U8CZgxyJ/14h6n4K1pIjNemFkKANJ8Q1fGBbVY0D/CSeL X-Received: by 2002:a17:906:3d21:b0:9a1:f96c:4baf with SMTP id l1-20020a1709063d2100b009a1f96c4bafmr6016087ejf.5.1694355069774; Sun, 10 Sep 2023 07:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694355069; cv=none; d=google.com; s=arc-20160816; b=FDXz+wEXHvORi+jZDjJ8pBqWFjQEcigieM84Hlr1Oj/L5PDCm12YM1MMGl6Xq1N2QM mNepvf4ahhmlUuf7rHDux9tA9WW96xV2/L8kiIqcztLwMrLV6l5YAgD7JI2TxSvOi+rS GvF9QDLd1oD+1T1aKykdkYthVnUZLbXrhArWvAqyYqFGd4zxKAgbgOSbwYkq710u0bEN M9UT1JphYk9e61D+iqPAHp0E8hMD+sEZVYPsB2zYOwIhNiYBDimWMrAB5FaEUrJtXexw mEIe4K4w21OfhqKvNeN4/kptBtWMVrxLI5zRS9txgz1xyg2n0yGiMdlN0x7dqPhulmwS r39Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=v4vOGrFzGItPN/1LsK2L9SfM5Jzj+zTc61qUaLDu7Ls=; fh=hKkF4Qm4zMpuuPSvBuLljwLCLYziV8/JqYgl0gS1cUA=; b=Y2/J0ZBGMR3Ft6EDLNnM6vk4AiFGz1pPMcTUxgk4hkUIkfFf3t+p+Avq9S8lkEzWbV GTu8huEL05Uahh187orR6HwVOaVPuJ6NVqqttRQStjnltG4dVHCMQk3mp9dTb0vZT2rM dkNjEqc3vTR0h6GKk5AUDmIN6+m5siLuPh+AsVqG3b5xod1L0ZG+XI1iyjmNCArJeiIx 3q9UUH/R19K0PsRBSopDPX5C2wI+OBv3kmCqmcA0dQFJaoGY/rIojNJ9K/r/P5QCzOJK 2VXOcApRO695OeUImd2TtjSPiAqI7Fs59XynYJt1V43yOyR2IjagseAJpheqWs1iR4Sg SuTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=st2Nvr2s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p12-20020a1709060e8c00b009942c859e77si5457391ejf.193.2023.09.10.07.11.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Sep 2023 07:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=st2Nvr2s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DD873858004 for ; Sun, 10 Sep 2023 14:11:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DD873858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694355068; bh=v4vOGrFzGItPN/1LsK2L9SfM5Jzj+zTc61qUaLDu7Ls=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=st2Nvr2s30qx56qF2Trd+c4aTj4vPS6BvvnizrqhgjM83bpMgkisFg4tr0+NySG9o bPen7o0UoZu7G6zeXzZboNJVdp583ckuqJrbRNNe0TDWYdfyjjnjFuaC7WcXj6Ryuw A0dBgU1K/99EO3MZLres/B0TpFMQpdHVnZHwzWoU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 761EE3858D33 for ; Sun, 10 Sep 2023 14:10:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 761EE3858D33 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-403012f27e3so14282895e9.3 for ; Sun, 10 Sep 2023 07:10:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694355024; x=1694959824; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=v4vOGrFzGItPN/1LsK2L9SfM5Jzj+zTc61qUaLDu7Ls=; b=q2FvSk5ssv+Pz7cNEFMd45xtibo7tFAm6ww2Qt2K9cafNE0PWdr8E+RJpJx12W1ptx dGAjavIXv4534m9dHaq1fQLPEG1U+3MJE7etfE6vpmP75hJ9hUhbPtdkpAL/pGCeEDKg UaI+LI12QloLu3TADT0YlrFNNo+Uj++wl8LaeaCrJEjh6z9XAcF83VsIXeHvLzXfBUpL +ZtoOBPn5Hq+Go0i1dsEJxgTs8/vEDFAQktL3C/DOXYq/R69DF57TQFVwxKKYzqY6RKS d/dRgNHuYOusiEYyg2AEbP8u6v3lahfPoikWNmbEthBMcC7nHHSvl+/hRY/LWONMBZue jfNA== X-Gm-Message-State: AOJu0YzvlwfV3tb2vaGZpNu81tf3eCixk5yRoEKYY97J5GO9tZjWYzhp 7+IN/cLampA9O1ZxoTXEksoC/jsdgrI= X-Received: by 2002:a7b:c84b:0:b0:401:d2cb:e6f2 with SMTP id c11-20020a7bc84b000000b00401d2cbe6f2mr5777299wml.32.1694355023806; Sun, 10 Sep 2023 07:10:23 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id p11-20020a1c740b000000b003ff013a4fd9sm7318981wmc.7.2023.09.10.07.10.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 10 Sep 2023 07:10:23 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] Darwin: Partial reversion of r14-3648 (Inits Section). Date: Sun, 10 Sep 2023 15:10:22 +0100 Message-Id: <20230910141022.89898-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 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.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: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776660061783037856 X-GMAIL-MSGID: 1776660061783037856 Tested on x86_64-darwin21 and i686-darwin9 with both dwarfutils and llvm-based dsymutil implementations. Pushed to trunk, thanks Iain --- 8< --- Although the Darwin ABI places both hot and cold partitions in the same section (the linker can partition by name), this does not work with the current dwarf2out implementation. Since we do see global initialization code getting hot/cold splits, this patch places the cold parts into text_cold, and keeps the hot part in the correct Init section per ABI. TODO: figure out a way to allow us to match the ABI fully. gcc/ChangeLog: * config/darwin.cc (darwin_function_section): Place unlikely executed global init code into the standard cold section. Signed-off-by: Iain Sandoe --- gcc/config/darwin.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 95d6194cf22..154a2b2755a 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3893,19 +3893,22 @@ darwin_function_section (tree decl, enum node_frequency freq, if (decl && DECL_SECTION_NAME (decl) != NULL) return get_named_section (decl, NULL, 0); + /* We always put unlikely executed stuff in the cold section; we have to put + this ahead of the global init section, since partitioning within a section + breaks some assumptions made in the DWARF handling. */ + if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED) + return (use_coal) ? darwin_sections[text_cold_coal_section] + : darwin_sections[text_cold_section]; + /* Intercept functions in global init; these are placed in separate sections. - FIXME: there should be some neater way to do this. */ + FIXME: there should be some neater way to do this, FIXME we should be able + to partition within a section. */ if (DECL_NAME (decl) && (startswith (IDENTIFIER_POINTER (DECL_NAME (decl)), "_GLOBAL__sub_I") || startswith (IDENTIFIER_POINTER (DECL_NAME (decl)), "__static_initialization_and_destruction"))) return darwin_sections[static_init_section]; - /* We always put unlikely executed stuff in the cold section. */ - if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED) - return (use_coal) ? darwin_sections[text_cold_coal_section] - : darwin_sections[text_cold_section]; - /* If we have LTO *and* feedback information, then let LTO handle the function ordering, it makes a better job (for normal, hot, startup and exit - hence the bailout for cold above). */