From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 5B2313858403; Thu, 18 Apr 2024 14:47:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B2313858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713451620; bh=WXJns1A4P+nsvEzPkiA7Or5gqcfDfeP/8zivDIbEPNg=; h=From:To:Subject:Date:From; b=JXp3xLLNR5gjNOQ2VG+ssU3BEuIzgZwqifaEERSAVN183ZKyiYDtE+F9XiVgGmT5P zUOOHXVaGUvHW9wCuBQidDZOD4qeVYXyx8sPO48/TfqRwAGZ2wtRDhBKyAA+cKN1HC mWn8RhZlOLU3KfgomNdnYopL0gSUwK42zQLbka6U= 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 r12-10342] Darwin: Partial reversion of r14-3648 (Inits Section). X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 11d379f5ff8a5d3ce3ec4bc2f66471cab15c9ff7 X-Git-Newrev: a732f63ebc032fbcd7740156d497472d16bdea50 Message-Id: <20240418144700.5B2313858403@sourceware.org> Date: Thu, 18 Apr 2024 14:47:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a732f63ebc032fbcd7740156d497472d16bdea50 commit r12-10342-ga732f63ebc032fbcd7740156d497472d16bdea50 Author: Iain Sandoe Date: Sun Sep 10 14:48:42 2023 +0100 Darwin: Partial reversion of r14-3648 (Inits Section). 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 (cherry picked from commit 5b33b364652866165431aef1810af1e890229c5e) Diff: --- 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 68a692dc74e..8f039de1d8d 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3879,19 +3879,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). */