[PATCH] D120327: compiler-rt: Add udivmodei5 to builtins and add bitint library

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 12:48:48 PDT 2022


efriedma added a comment.

Instead of putting the `__divmodei5`/`__udivmodei5` routines in compiler-rt, can we just make the backend embed them into the object file?

Fundamentally, adding new methods to the builtins library is problematic.  In general, we don't control the link step: we link against whatever builtins library the user provides, which is some random version of libgcc/compiler-rt.builtins/some handwritten replacement/etc.  So adding any new names will likely cause problems for users trying to use the new features.  Putting the name into a new "bitint" library is just going to confuse users more.

Really, we don't need the symbols to be in the builtins library; the implementation is entirely self-contained, so we can just emit it into the object files that need it.  We can make it weak+hidden with some LLVM-specific name to ensure we don't bloat the final executable.  The only complicated part is that the backend needs to generate the implementation, and it only understands LLVM IR, not C.

(I think this general approach would also be useful for other routines; for example, we currently emit overflowing arithmetic inline because there's no external implementation we can call.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120327/new/

https://reviews.llvm.org/D120327



More information about the llvm-commits mailing list