Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Oliver Sang <oliver.sang@intel.com>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	llvm@lists.linux.dev, kernel test robot <lkp@intel.com>,
	oe-kbuild-all@lists.linux.dev
Subject: Re: [jgunthorpe:iommu_pt_vtd 8/34] ERROR: modpost: "__udivdi3" [drivers/iommu/generic_pt/fmt/iommu_amdv1.ko] undefined!
Date: Wed, 17 Sep 2025 15:12:17 -0700	[thread overview]
Message-ID: <20250917221217.GA650176@ax162> (raw)
In-Reply-To: <20250917112214.GY1086830@nvidia.com>

On Wed, Sep 17, 2025 at 08:22:14AM -0300, Jason Gunthorpe wrote:
> On Tue, Sep 16, 2025 at 07:20:43PM -0700, Nathan Chancellor wrote:
> > as the bad commit, which certainly makes sense, as C23 made this GCC
> > extension as part of the standard so clang needed to account for that.
> > As far as I can tell, GCC did the same thing in
> > 
> >   https://gcc.gnu.org/cgit/gcc/commit/?id=3b3083a598ca3f4b6203284e01ed39ab6ff0844f
> > 
> >   "The standard feature gives all the values of such an enum the enumerated
> >   type (while keeping type int if that can represent all values of the
> >   enumeration), where previously GCC only gave those values outside the range
> >   of int the enumerated type... this patch makes the change to types of
> >   enumerators unconditionally (if that causes problems in practice we could
> >   always make it conditional on C2x mode instead)."
> 
> That makes sense, I did not know it had changed like that
> 
> But still, I'd expect the compiler to retain the original behavior
> unless std23/gnu23 is specified given that it does change codegen and
> causes errors.
> 
> Though that is even more perplexing if gcc has been working this way
> since 13 why does it avoid the udiv..

Looking at the preprocessed source and making some educated guesses, I
am guessing with inlining and constant folding, GCC turn division into
multiplication by the reciprocal. Clang implements some of these
optimizations but not all, if I remember correctly.

Cheers,
Nathan

  reply	other threads:[~2025-09-17 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <202508271856.ixwxgh3g-lkp@intel.com>
     [not found] ` <20250902124856.GE186519@nvidia.com>
     [not found]   ` <aMj38M8HeDSQHQPf@xsang-OptiPlex-9020>
2025-09-16 14:12     ` [jgunthorpe:iommu_pt_vtd 8/34] ERROR: modpost: "__udivdi3" [drivers/iommu/generic_pt/fmt/iommu_amdv1.ko] undefined! Jason Gunthorpe
2025-09-17  2:20       ` Nathan Chancellor
2025-09-17 11:22         ` Jason Gunthorpe
2025-09-17 22:12           ` Nathan Chancellor [this message]
2025-09-18  0:06             ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250917221217.GA650176@ax162 \
    --to=nathan@kernel.org \
    --cc=jgg@nvidia.com \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox