Skip to content

Commit bc15899

Browse files
committed
Reenable use of divmod compiler_rt functions for iOS 5.0 and later.
llvm-svn: 141368
1 parent b7609cd commit bc15899

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@ ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
422422
setLibcallName(RTLIB::MEMSET, "__aeabi_memset");
423423
}
424424

425+
// Use divmod compiler-rt calls for iOS 5.0 and later.
426+
if (Subtarget->getTargetTriple().getOS() == Triple::IOS &&
427+
!Subtarget->getTargetTriple().isOSVersionLT(5, 0)) {
428+
setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4");
429+
setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4");
430+
}
431+
425432
if (Subtarget->isThumb1Only())
426433
addRegisterClass(MVT::i32, ARM::tGPRRegisterClass);
427434
else

llvm/test/CodeGen/ARM/divmod.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; RUN: llc < %s -mtriple=arm-apple-ios5.0 | FileCheck %s
2+
3+
define void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
4+
entry:
5+
; CHECK: foo:
6+
; CHECK: bl ___divmodsi4
7+
; CHECK-NOT: bl ___divmodsi4
8+
%div = sdiv i32 %x, %y
9+
store i32 %div, i32* %P, align 4
10+
%rem = srem i32 %x, %y
11+
%arrayidx6 = getelementptr inbounds i32* %P, i32 1
12+
store i32 %rem, i32* %arrayidx6, align 4
13+
ret void
14+
}
15+
16+
define void @bar(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
17+
entry:
18+
; CHECK: bar:
19+
; CHECK: bl ___udivmodsi4
20+
; CHECK-NOT: bl ___udivmodsi4
21+
%div = udiv i32 %x, %y
22+
store i32 %div, i32* %P, align 4
23+
%rem = urem i32 %x, %y
24+
%arrayidx6 = getelementptr inbounds i32* %P, i32 1
25+
store i32 %rem, i32* %arrayidx6, align 4
26+
ret void
27+
}
28+
29+
; rdar://9280991
30+
@flags = external unnamed_addr global i32
31+
@tabsize = external unnamed_addr global i32
32+
33+
define void @do_indent(i32 %cols) nounwind {
34+
entry:
35+
; CHECK: do_indent:
36+
%0 = load i32* @flags, align 4
37+
%1 = and i32 %0, 67108864
38+
%2 = icmp eq i32 %1, 0
39+
br i1 %2, label %bb1, label %bb
40+
41+
bb:
42+
; CHECK: bl ___divmodsi4
43+
%3 = load i32* @tabsize, align 4
44+
%4 = srem i32 %cols, %3
45+
%5 = sdiv i32 %cols, %3
46+
%6 = tail call i32 @llvm.objectsize.i32(i8* null, i1 false)
47+
%7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind
48+
br label %bb1
49+
50+
bb1:
51+
%line_indent_len.0 = phi i32 [ %4, %bb ], [ 0, %entry ]
52+
%8 = getelementptr inbounds i8* null, i32 %line_indent_len.0
53+
store i8 0, i8* %8, align 1
54+
ret void
55+
}
56+
57+
declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readnone
58+
declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind

0 commit comments

Comments
 (0)