From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B105C4332F for ; Thu, 13 Oct 2022 17:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zONRmFKRD/2n1/6UCNAiKycz09GV0zv8vDtBIpc+geo=; b=jithpFX4U3xH2o T0u1bnOD4YjbvMDazDfF5q4+CjRkxs4SYTixYUD9JOzziD291FFOqv578YTHG2TdevlPTXEc5HgeM OwBky48zFh87e9057K6rp2btfuPmkGAWlXGwfRl09LO56xRXv42WaXa8KOU2Iceb9xa7fvVtxYgvU vmxGMej4di0UdYVDMBrLeB2+Z/cAsZmkU5oeROjNC9aaYEXuTt68+Q0F7q8qV5owiKxhLsOv/V2+q JmB3neIlFf4e7oTfGnEdwelrv+odIT2UyBh8pjBG8hWupyFL+eAxjJ8GNF2t32lyD5Ypsv8oDg4Pf wv/J2ats23PGuMLQG2tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj1d7-00CV4m-97; Thu, 13 Oct 2022 17:04:21 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj1d3-00CV3c-S1 for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 17:04:19 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 703C461842; Thu, 13 Oct 2022 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 163F6C433D6; Thu, 13 Oct 2022 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665680653; bh=zqOuGPwa/tbxCln5Vk/B7tJrtXrhT4FfMEgYWQ0zc2M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kxkBFjZ9yx1EkrjGwoOmLrOJbSez+G02Qx4igiM6FEScURddkjIotAnbByplsRJ+m NIPVRgSQM9v3QhHMR6t3ceR9vEznkv4i8JLgPgBTDv1mz0/RzJHUy7PkYeG/ncEOQ8 3Jhx0704ENuzSUevRD9rM7TDNjU8JOCeLSzreGdzdN5vmiizVdBHTkKr66SwqiIzBT B8nxctR2iXhO8YmDtFTA4ExfXPwdzdc0kMQM89ykZwlTtVFNRprUoh2/+s3TEf6iZg kBRFWV8wJPoq16RnHWGpt2sIP7sujrKjZNxvxl3fdSvvlh6lc8s01bSTTJsIaCd1Qm eWKTrmpCDFEtw== Date: Thu, 13 Oct 2022 10:04:11 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Arnd Bergmann , Russell King , Tom Rix , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , Ard Biesheuvel , Gary Guo , Craig Topper , Philip Reames , jh@jhauser.us Subject: Re: [PATCH] ARM: NWFPE: avoid compiler-generated __aeabi_uldivmod Message-ID: References: <20221010225342.3903590-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010225342.3903590-1-ndesaulniers@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_100418_021526_648D3AC8 X-CRM114-Status: GOOD ( 27.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 10, 2022 at 03:53:42PM -0700, Nick Desaulniers wrote: > clang-15's ability to elide loops completely became more aggressive when > it can deduce how a variable is being updated in a loop. Counting down > one variable by an increment of another can be replaced by a modulo > operation. > > For 64b variables on 32b ARM EABI targets, this can result in the > compiler generating calls to __aeabi_uldivmod, which it does for a do > while loop in float64_rem(). > > For the kernel, we'd generally prefer that developers not open code 64b > division via binary / operators and instead use the more explicit > helpers from div64.h. On arm-linux-gnuabi targets, failure to do so can > result in linkage failures due to undefined references to > __aeabi_uldivmod(). > > While developers can avoid open coding divisions on 64b variables, the > compiler doesn't know that the Linux kernel has a partial implementation > of a compiler runtime (--rtlib) to enforce this convention. > > It's also undecidable for the compiler whether the code in question > would be faster to execute the loop vs elide it and do the 64b division. > > While I actively avoid using the internal -mllvm command line flags, I > think we get better code than using barrier() here, which will force > reloads+spills in the loop for all toolchains. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1666 > Reported-by: Nathan Chancellor > Signed-off-by: Nick Desaulniers I built ARCH=arm allmodconfig + CONFIG_WERROR=n without this patch and saw the link failure then applied it and the error went away. Thanks for all the investigation done into fixing this! I think you put this in the patch tracker already but just for posterity: Tested-by: Nathan Chancellor > --- > arch/arm/nwfpe/Makefile | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/arm/nwfpe/Makefile b/arch/arm/nwfpe/Makefile > index 303400fa2cdf..2aec85ab1e8b 100644 > --- a/arch/arm/nwfpe/Makefile > +++ b/arch/arm/nwfpe/Makefile > @@ -11,3 +11,9 @@ nwfpe-y += fpa11.o fpa11_cpdo.o fpa11_cpdt.o \ > entry.o > > nwfpe-$(CONFIG_FPE_NWFPE_XP) += extended_cpdo.o > + > +# Try really hard to avoid generating calls to __aeabi_uldivmod() from > +# float64_rem() due to loop elision. > +ifdef CONFIG_CC_IS_CLANG > +CFLAGS_softfloat.o += -mllvm -replexitval=never > +endif > -- > 2.38.0.rc2.412.g84df46c1b4-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel