[PATCH] D78300: [builtins] Do not assume CHAR_BIT==8 in int_div_impl.inc

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 07:48:47 PDT 2020


bjope created this revision.
bjope added a reviewer: MaskRay.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Got some regressions downstream after commit b541196eb45d80f2d <https://reviews.llvm.org/rGb541196eb45d80f2dacd76e16828963760c3850d>
due to the new code assuming CHAR_BIT==8. This is a fixup for
that problem.

And while being at it, also adding the missing file header.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78300

Files:
  compiler-rt/lib/builtins/int_div_impl.inc


Index: compiler-rt/lib/builtins/int_div_impl.inc
===================================================================
--- compiler-rt/lib/builtins/int_div_impl.inc
+++ compiler-rt/lib/builtins/int_div_impl.inc
@@ -1,4 +1,16 @@
-#define clz(a) (sizeof(a) == 8 ? __builtin_clzll(a) : __builtin_clz(a))
+//===----- int_div_impl.inc - integer division --------------------*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements helpers for udivXi3 and umodXi3.
+//
+//===----------------------------------------------------------------------===//
+
+#define clz(a) (sizeof(a) * CHAR_BIT == 64 ? __builtin_clzll(a) : __builtin_clz(a))
 
 // Adapted from Figure 3-40 of The PowerPC Compiler Writer's Guide
 static __inline fixuint_t __udivXi3(fixuint_t n, fixuint_t d) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78300.258052.patch
Type: text/x-patch
Size: 1045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/0f047b7e/attachment-0001.bin>


More information about the llvm-commits mailing list