[PATCH] D31716: [Builtins] Fix div0 error in udivsi3

Weiming Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 23:26:18 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL299628: [Builtins] Fix div0 error in udivsi3 (authored by weimingz).

Changed prior to commit:
  https://reviews.llvm.org/D31716?vs=94270&id=94318#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31716

Files:
  compiler-rt/trunk/lib/builtins/arm/udivsi3.S


Index: compiler-rt/trunk/lib/builtins/arm/udivsi3.S
===================================================================
--- compiler-rt/trunk/lib/builtins/arm/udivsi3.S
+++ compiler-rt/trunk/lib/builtins/arm/udivsi3.S
@@ -37,7 +37,16 @@
 	beq     LOCAL_LABEL(divby0)
 	udiv	r0, r0, r1
 	bx  	lr
-#else
+
+LOCAL_LABEL(divby0):
+	mov     r0, #0
+#  ifdef __ARM_EABI__
+	b       __aeabi_idiv0
+#  else
+	JMP(lr)
+#  endif
+
+#else /* ! __ARM_ARCH_EXT_IDIV__ */
 	cmp	r1, #1
 	bcc	LOCAL_LABEL(divby0)
 #if __ARM_ARCH_ISA_THUMB == 1
@@ -186,9 +195,12 @@
 LOCAL_LABEL(divby0):
 	movs	r0, #0
 #      if defined(__ARM_EABI__)
+	push {r7, lr}
 	bl	__aeabi_idiv0 // due to relocation limit, can't use b.
-#      endif
+	pop  {r7, pc}
+#      else
 	JMP(lr)
+#      endif
 
 
 #if __ARM_ARCH_ISA_THUMB == 1
@@ -252,16 +264,6 @@
 	JMP(lr)
 #endif /* __ARM_ARCH_EXT_IDIV__ */
 
-#if __ARM_ARCH_EXT_IDIV__
-LOCAL_LABEL(divby0):
-        mov     r0, #0
-#  ifdef __ARM_EABI__
-        b       __aeabi_idiv0
-#  else
-        JMP(lr)
-#  endif
-#endif
-
 END_COMPILERRT_FUNCTION(__udivsi3)
 
 NO_EXEC_STACK_DIRECTIVE


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31716.94318.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170406/b1136806/attachment.bin>


More information about the llvm-commits mailing list