Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5c91b98

Browse filesBrowse files
[ARMISelLowering] avoid emitting libcalls to __mulodi4()
__has_builtin(__builtin_mul_overflow) returns true for 32b ARM targets, but Clang is deferring to compiler RT when encountering `long long` types. This breaks sanitizer 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 allmodconfig builds of the Linux kernel for this target with older releases of clang. Link: https://bugs.llvm.org/show_bug.cgi?id=28629 Link: ClangBuiltLinux/linux#1438 Reviewed By: rengolin Differential Revision: https://reviews.llvm.org/D108842
1 parent 0a7b8cc commit 5c91b98
Copy full SHA for 5c91b98

File tree

Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed

‎llvm/lib/Target/ARM/ARMISelLowering.cpp

Copy file name to clipboardExpand all lines: llvm/lib/Target/ARM/ARMISelLowering.cpp
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
545545
setLibcallName(RTLIB::SRL_I128, nullptr);
546546
setLibcallName(RTLIB::SRA_I128, nullptr);
547547
setLibcallName(RTLIB::MUL_I128, nullptr);
548+
setLibcallName(RTLIB::MULO_I64, nullptr);
549+
setLibcallName(RTLIB::MULO_I128, nullptr);
548550

549551
// RTLIB
550552
if (Subtarget->isAAPCS_ABI() &&

‎llvm/test/CodeGen/ARM/overflow-intrinsic-optimizations.ll

Copy file name to clipboardExpand all lines: llvm/test/CodeGen/ARM/overflow-intrinsic-optimizations.ll
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,27 @@ while.end:
234234
ret i32 %conv
235235
}
236236

237+
define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) {
238+
; CHECK-LABEL: no__mulodi4
239+
; CHECK-NOT: bl __mulodi4
240+
entry:
241+
%0 = sext i32 %a to i64
242+
%1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b)
243+
%2 = extractvalue { i64, i1 } %1, 1
244+
%3 = extractvalue { i64, i1 } %1, 0
245+
%4 = trunc i64 %3 to i32
246+
%5 = sext i32 %4 to i64
247+
%6 = icmp ne i64 %3, %5
248+
%7 = or i1 %2, %6
249+
store i32 %4, i32* %c, align 4
250+
ret i1 %7
251+
}
252+
237253
declare void @llvm.trap() #2
238254
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
239255
declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) #1
240256
declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1
241257
declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) #1
242258
declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #1
243259
declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) #1
260+
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.