[all-commits] [llvm/llvm-project] a3b745: [libc] add unsafe mode to strlen

michaelrj-google via All-commits all-commits at lists.llvm.org
Wed Nov 30 16:48:48 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a3b745818d2e13b2899260239c7cab4bf75070f7
      https://github.com/llvm/llvm-project/commit/a3b745818d2e13b2899260239c7cab4bf75070f7
  Author: Michael Jones <michaelrj at google.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    M libc/CMakeLists.txt
    A libc/common_libc_tuners.cmake
    M libc/src/string/CMakeLists.txt
    M libc/src/string/string_utils.h

  Log Message:
  -----------
  [libc] add unsafe mode to strlen

The only safe way to implement strlen involves reading the string one
char at a time. It is faster to read in larger blocks, but this leads to
reading beyond the string boundary, which is undefined behavior. This
patch adds an implementation and flag to use this fast but unsafe
version of strlen.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D129808




More information about the All-commits mailing list