Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 6b34053

Browse files
author
Weiming Zhao
committed
[Builtins] Fix div0 error in udivsi3
Summary: Need to save `lr` before bl to aeabi_div0 Reviewers: rengolin, compnerd Reviewed By: compnerd Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31716 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299628 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9f4261c commit 6b34053

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/builtins/arm/udivsi3.S

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ DEFINE_COMPILERRT_FUNCTION(__udivsi3)
3737
beq LOCAL_LABEL(divby0)
3838
udiv r0, r0, r1
3939
bx lr
40-
#else
40+
41+
LOCAL_LABEL(divby0):
42+
mov r0, #0
43+
# ifdef __ARM_EABI__
44+
b __aeabi_idiv0
45+
# else
46+
JMP(lr)
47+
# endif
48+
49+
#else /* ! __ARM_ARCH_EXT_IDIV__ */
4150
cmp r1, #1
4251
bcc LOCAL_LABEL(divby0)
4352
#if __ARM_ARCH_ISA_THUMB == 1
@@ -186,9 +195,12 @@ LOCAL_LABEL(skip_1):
186195
LOCAL_LABEL(divby0):
187196
movs r0, #0
188197
# if defined(__ARM_EABI__)
198+
push {r7, lr}
189199
bl __aeabi_idiv0 // due to relocation limit, can't use b.
190-
# endif
200+
pop {r7, pc}
201+
# else
191202
JMP(lr)
203+
# endif
192204

193205

194206
#if __ARM_ARCH_ISA_THUMB == 1
@@ -252,16 +264,6 @@ LOCAL_LABEL(div0block):
252264
JMP(lr)
253265
#endif /* __ARM_ARCH_EXT_IDIV__ */
254266

255-
#if __ARM_ARCH_EXT_IDIV__
256-
LOCAL_LABEL(divby0):
257-
mov r0, #0
258-
# ifdef __ARM_EABI__
259-
b __aeabi_idiv0
260-
# else
261-
JMP(lr)
262-
# endif
263-
#endif
264-
265267
END_COMPILERRT_FUNCTION(__udivsi3)
266268

267269
NO_EXEC_STACK_DIRECTIVE

0 commit comments

Comments
 (0)