[PATCH] D42902: [compiler-rt] Workaround for endless recursion in ctzdi2

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 03:17:13 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT324593: [builtins] Workaround for infinite recursion in c?zdi2 (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42902?vs=132817&id=133393#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42902

Files:
  lib/builtins/clzdi2.c
  lib/builtins/ctzdi2.c


Index: lib/builtins/ctzdi2.c
===================================================================
--- lib/builtins/ctzdi2.c
+++ lib/builtins/ctzdi2.c
@@ -16,6 +16,12 @@
 
 /* Returns: the number of trailing 0-bits  */
 
+#if !defined(__clang__) && (defined(__sparc64__) || defined(__mips64) || defined(__riscv__))
+/* gcc resolves __builtin_ctz -> __ctzdi2 leading to infinite recursion */
+#define __builtin_ctz(a) __ctzsi2(a)
+extern si_int __ctzsi2(si_int);
+#endif
+
 /* Precondition: a != 0 */
 
 COMPILER_RT_ABI si_int
Index: lib/builtins/clzdi2.c
===================================================================
--- lib/builtins/clzdi2.c
+++ lib/builtins/clzdi2.c
@@ -16,6 +16,12 @@
 
 /* Returns: the number of leading 0-bits */
 
+#if !defined(__clang__) && (defined(__sparc64__) || defined(__mips64) || defined(__riscv__))
+/* gcc resolves __builtin_clz -> __clzdi2 leading to infinite recursion */
+#define __builtin_clz(a) __clzsi2(a)
+extern si_int __clzsi2(si_int);
+#endif
+
 /* Precondition: a != 0 */
 
 COMPILER_RT_ABI si_int


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42902.133393.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180208/b9105fe1/attachment.bin>


More information about the llvm-commits mailing list