From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 346A93858C2F for ; Thu, 19 Oct 2023 15:16:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 346A93858C2F 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 346A93858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697728612; cv=none; b=XjyVOB6de0WjsH328ZUhqPshX/AdEiBHsh4fDFfW8lWhR95NOTv7LhYJv5G8AI/e/db1Q/VvBniI2eacwJM9kZUlkY+A+Q7T7YFMTcQ7Y/iIq+w+snRHABIRlkNQCUhIQ9my+UPA40GOOF6GBPdjy/qmi6OXWunzYf+JnYGoHag= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697728612; c=relaxed/simple; bh=uDYC89X1xiI21RJCp4cRmPJbAX5p2T1Ll7Y26IHRNys=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=li20YeVE8XbPhnvwtJwglAF4uDsd/0Bb2SaBuqSUxI3ctuzRg9IBKP5pfQddbseO2+rvwWe3BhytWHGjN1d/h2veAa1WmnIfHraySusIEYsqoUBwzovcBn/X073zNYlsLfkotWXqdb5Gm9YlJw654L0t/1naUSvqVELnH3PetNk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6b6f4c118b7so5074565b3a.0 for ; Thu, 19 Oct 2023 08:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697728609; x=1698333409; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XrC3FcDPd8Rv4br2zPuFc/HXM8bQDGrZ+jWOARB6Cec=; b=gi0yRL1+M0U+l9k6tvh4jco1O+A9MA7SpmfUBY94X5fSexhEa5WlhpbaqW0G/DNGTR qclS2j/nIVFjLVzmImkYj1L3BEnnsJM2v30/qY9UTkuDnL3kKywIa3euvmTVf9B9WGyl 1y5+IQglx70+Ao9tz+4hrQMBkitUVix9UaeE5SPNLIAK5gwd5PiH00NPXX2vIGrUS3ra BHQdN5F4x2CnieASqy/aY6HtiBbAD7PLcL3wa0iSISKZTNetlOVRmXwZ/s2B9vRg1jca I6JgkcE9lFY+8JPp9mUYVOWRKlglzwTQ4x/rZjhNwAQVAHF2CL6cuqqmFafb+bKVEbUC W4Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697728609; x=1698333409; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XrC3FcDPd8Rv4br2zPuFc/HXM8bQDGrZ+jWOARB6Cec=; b=mtRqHLg064T/7P4ZDuVpiYU7WWzftEApER1bJVKwdgVyYusE0B+EJ5Zw1xSiVr25UL WcY1rIXRJMHBkqEiLVGGirN6WeyLoRUM4uko7Cnkd5OYoZlhG6fJtxsj3doI7M9GCj08 Y7oEwiPrxHsOvB6UCrKDMxrdBU0NRQUSveDF5LPEFcGnCf1W9f+ORnFDh3ZqcS62mjFx j8OjvQU4D6DCmJaMQ0uXtvBiZ2GEV48t4L+MPBvzMSim82V2Xl6zOp+wi2pbkagTupc5 o1y1OGGHcWcmLzdDcBpFWCEjlHAFJGmG5IxZclta9jUlsIZWKffflO2x1VUDmAcRT9XF r0mQ== X-Gm-Message-State: AOJu0YzbuwU370TB5TXDUZIBjEV9LtLO1e+6eas11dSfLvZraP3gIDLt SAUoxhrlhyrz5eXC5/emhlj9LOJcmtM= X-Google-Smtp-Source: AGHT+IFXC0zJwhLK4aJrd4Pv0mpRRb1YpcMKanis6oIphQELskX0STxpFkRe7fL+SeW5uSk/L7/1FQ== X-Received: by 2002:a05:6a00:cd5:b0:68f:e810:e86f with SMTP id b21-20020a056a000cd500b0068fe810e86fmr2634065pfv.28.1697728608935; Thu, 19 Oct 2023 08:16:48 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id p129-20020a625b87000000b00692aea7fb29sm5407018pfb.88.2023.10.19.08.16.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 08:16:48 -0700 (PDT) Message-ID: <9e07442e-0e3f-4766-8d7d-9b849851f514@gmail.com> Date: Thu, 19 Oct 2023 09:16:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/11] Handle epilogues that contain jumps Content-Language: en-US To: Richard Biener , Szabolcs Nagy , gcc-patches@gcc.gnu.org, Kyrylo.Tkachov@arm.com, richard.earnshaw@arm.com, richard.sandiford@arm.com References: <103b7db0ce64fb9f2757e1a7d98cb7fa3103c4f2.1692699125.git.szabolcs.nagy@arm.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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,KAM_SHORT,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 List-Id: On 10/17/23 03:19, Richard Biener wrote: > On Thu, Oct 12, 2023 at 10:15 AM Richard Sandiford > wrote: >> >> Richard Biener writes: >>> On Tue, Aug 22, 2023 at 12:42 PM Szabolcs Nagy via Gcc-patches >>> wrote: >>>> >>>> From: Richard Sandiford >>>> >>>> The prologue/epilogue pass allows the prologue sequence >>>> to contain jumps. The sequence is then partitioned into >>>> basic blocks using find_many_sub_basic_blocks. >>>> >>>> This patch treats epilogues in the same way. It's needed for >>>> a follow-on aarch64 patch that adds conditional code to both >>>> the prologue and the epilogue. >>>> >>>> Tested on aarch64-linux-gnu (including with a follow-on patch) >>>> and x86_64-linux-gnu. OK to install? >>>> >>>> Richard >>>> >>>> gcc/ >>>> * function.cc (thread_prologue_and_epilogue_insns): Handle >>>> epilogues that contain jumps. >>>> --- >>>> >>>> This is a previously approved patch that was not committed >>>> because it was not needed at the time, but i'd like to commit >>>> it as it is needed for the followup aarch64 eh_return changes: >>>> >>>> https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605769.html >>>> >>>> --- >>>> gcc/function.cc | 10 ++++++++++ >>>> 1 file changed, 10 insertions(+) >>>> >>>> diff --git a/gcc/function.cc b/gcc/function.cc >>>> index dd2c1136e07..70d1cd65303 100644 >>>> --- a/gcc/function.cc >>>> +++ b/gcc/function.cc >>>> @@ -6120,6 +6120,11 @@ thread_prologue_and_epilogue_insns (void) >>>> && returnjump_p (BB_END (e->src))) >>>> e->flags &= ~EDGE_FALLTHRU; >>>> } >>>> + >>>> + auto_sbitmap blocks (last_basic_block_for_fn (cfun)); >>>> + bitmap_clear (blocks); >>>> + bitmap_set_bit (blocks, BLOCK_FOR_INSN (epilogue_seq)->index); >>>> + find_many_sub_basic_blocks (blocks); >>>> } >>>> else if (next_active_insn (BB_END (exit_fallthru_edge->src))) >>>> { >>>> @@ -6218,6 +6223,11 @@ thread_prologue_and_epilogue_insns (void) >>>> set_insn_locations (seq, epilogue_location); >>>> >>>> emit_insn_before (seq, insn); >>>> + >>>> + auto_sbitmap blocks (last_basic_block_for_fn (cfun)); >>>> + bitmap_clear (blocks); >>>> + bitmap_set_bit (blocks, BLOCK_FOR_INSN (insn)->index); >>>> + find_many_sub_basic_blocks (blocks); >>> >>> I'll note that clearing a full sbitmap to pass down a single basic block >>> to find_many_sub_basic_blocks is a quite expensive operation. May I suggest >>> to add an overload operating on a single basic block? It's only >>> >>> FOR_EACH_BB_FN (bb, cfun) >>> SET_STATE (bb, >>> bitmap_bit_p (blocks, bb->index) ? BLOCK_TO_SPLIT : >>> BLOCK_ORIGINAL); >>> >>> using the bitmap, so factoring the rest of the function and customizing this >>> walk would do the trick. Note that the whole function could be refactored to >>> handle single blocks more efficiently. >> >> Sorry for the late reply, but does this look OK? Tested on >> aarch64-linux-gnu and x86_64-linux-gnu. > > LGTM, not sure if I'm qualified enough to approve though (I think you > are more qualified here, so ..) It looks quite sensible to me. Jeff