[PPCISelLowering] avoid emitting libcalls to __mulodi4()
authorNick Desaulniers <ndesaulniers@google.com>
Tue, 31 Aug 2021 18:00:08 +0000 (11:00 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Tue, 31 Aug 2021 18:09:58 +0000 (11:09 -0700)
commitd8b6ae072d7734e2abadd54ecddfd6cb77b7e4c0
tree28b26f20ce6c5d05b241375e350298ef9d1f97eb
parentc49503a76db5f91b2dbae28f4154df5b3891f7a1
[PPCISelLowering] avoid emitting libcalls to __mulodi4()

Similar to D108842, D108844, and D108926.

__has_builtin(builtin_mul_overflow) returns true for 32b PPC targets,
but Clang is deferring to compiler RT when encountering long long types.
This breaks ppc44x_defconfig + 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://github.com/ClangBuiltLinux/linux/issues/1438
Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D108936
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll [new file with mode: 0644]