Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: ClangBuiltLinux/linux#1438 Reviewed By: lebedev.ri, RKSimon Differential Revision: https://reviews.llvm.org/D108928
- Loading branch information
1 parent
c9e9635
commit d0eeb64
Showing
4 changed files
with
395 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; RUN: llc %s -mtriple=i386 -o - | FileCheck %s | ||
|
||
define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) { | ||
; CHECK-LABEL: no__mulodi4: | ||
; CHECK-NOT: calll __mulodi4 | ||
entry: | ||
%0 = sext i32 %a to i64 | ||
%1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b) | ||
%2 = extractvalue { i64, i1 } %1, 1 | ||
%3 = extractvalue { i64, i1 } %1, 0 | ||
%4 = trunc i64 %3 to i32 | ||
%5 = sext i32 %4 to i64 | ||
%6 = icmp ne i64 %3, %5 | ||
%7 = or i1 %2, %6 | ||
store i32 %4, i32* %c, align 4 | ||
ret i1 %7 | ||
} | ||
|
||
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.