[X86ISelLowering] avoid emitting libcalls to __mulodi4()
authorNick Desaulniers <ndesaulniers@google.com>
Tue, 7 Sep 2021 17:26:22 +0000 (10:26 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Tue, 7 Sep 2021 17:44:54 +0000 (10:44 -0700)
commitd0eeb64be5848a7832d13db9d69904db281d02e8
treea9a96d01bde3bddc7280c096a50040370ef0c216
parentc9e9635ffef781c32a839a77d122d7930edfc9b2
[X86ISelLowering] avoid emitting libcalls to __mulodi4()

Similar to D108842, D108844, and D108926.

__has_builtin(builtin_mul_overflow) returns true for 32b x86 targets,
but Clang is deferring to compiler RT when encountering long long types.
This breaks ARCH=i386 + CONFIG_BLK_DEV_NBD=y builds of the Linux kernel
that are using builtin_mul_overflow with these types for these targets.

If the semantics of __has_builtin mean "the compiler resolves these,
always" then we shouldn't conditionally emit a libcall.

This will still need to be worked around in the Linux kernel in order to
continue to support these builds of the Linux kernel for this
target with older releases of clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=28629
Link: https://bugs.llvm.org/show_bug.cgi?id=35922
Link: https://github.com/ClangBuiltLinux/linux/issues/1438
Reviewed By: lebedev.ri, RKSimon

Differential Revision: https://reviews.llvm.org/D108928
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/overflow-intrinsic-optimizations.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/smul_fix_sat.ll
llvm/test/CodeGen/X86/xmulo.ll