[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <05cdb3b4c9bddf25f7b839229b635d2dec5140a4.camel@xry111.site>
Date: Sat, 21 Dec 2024 15:40:12 +0800
From: Xi Ruoyao <xry111@...111.site>
To: Nathan Chancellor <nathan@...nel.org>, Peter Zijlstra
<peterz@...radead.org>
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>, Alex Deucher
<alexdeucher@...il.com>, Josh Poimboeuf <jpoimboe@...nel.org>, Huacai Chen
<chenhuacai@...nel.org>, loongarch@...ts.linux.dev,
amd-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org, Nick
Desaulniers <ndesaulniers@...gle.com>, llvm@...ts.linux.dev
Subject: Re: [PATCH v6 9/9] drm/amd/display: Mark dc_fixpt_from_fraction()
noinline
On Fri, 2024-12-20 at 15:34 -0700, Nathan Chancellor wrote:
> > Now, the thing is, these ASSERT()s are checking for divide-by-zero, I
> > suspect clang figured that out and invokes UB on us and just stops
> > code-gen.
>
> Yeah, I think your analysis is spot on, as this was introduced by a
> change in clang from a few months ago according to my bisect:
>
> https://github.com/llvm/llvm-project/commit/37932643abab699e8bb1def08b7eb4eae7ff1448
>
> Since the ASSERT does not do anything to prevent the divide by zero (it
> just flags it with WARN_ON) and the rest of the code doesn't either, I
> assume that the codegen stops as soon as it encounters the unreachable
> that change created from the path where divide by zero would occur via
>
> dc_fixpt_recip() ->
> dc_fixpt_from_fraction() ->
> complete_integer_division_u64() ->
> div64_u64_rem()
>
> Shouldn't callers of division functions harden them against dividing by
> zero?
Yes I think it'd be the correct solution.
--
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University
Powered by blists - more mailing lists