[all-commits] [llvm/llvm-project] 1d5c16: [libc] default enable -ftrivial-auto-var-init=patt...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Mon Jan 22 14:56:02 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1d5c16d7805806e920feee2b4ec93d5800293837
      https://github.com/llvm/llvm-project/commit/1d5c16d7805806e920feee2b4ec93d5800293837
  Author: Nick Desaulniers <nickdesaulniers at users.noreply.github.com>
  Date:   2024-01-22 (Mon, 22 Jan 2024)

  Changed paths:
    M libc/cmake/modules/CheckCompilerFeatures.cmake
    M libc/cmake/modules/LLVMLibCObjectRules.cmake
    M utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

  Log Message:
  -----------
  [libc] default enable -ftrivial-auto-var-init=pattern (#78776)

Usage of uninitialized memory is a top memory safety issue in C++ codebases.
Help mitigate this somewhat by default initialize stack allocations to a
pattern (0xAA repeating).

Clang has received optimizations to sink these into control flow paths that
access such values to minimize the overhead of these added initializations.

If there's a measurable slowdown, we can add
-ftrivial-auto-var-init-max-size=<N> for some value N bytes if we have any
large stack allocations, or add attribute uninitialized to any variable
declarations.

Unsupported until GCC 12.1 / Clang 8.

Increases file size of libc.a from a full build by +8.79Ki (+0.2%).




More information about the All-commits mailing list