[all-commits] [llvm/llvm-project] 732ad8: [clang][auto-init] Provide __builtin_alloca*_unini...

Marco Elver via All-commits all-commits at lists.llvm.org
Wed Jan 12 06:20:44 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 732ad8ea62edc403727af57537b5d83dcfa937aa
      https://github.com/llvm/llvm-project/commit/732ad8ea62edc403727af57537b5d83dcfa937aa
  Author: Marco Elver <elver at google.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M clang/include/clang/Basic/Builtins.def
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/CodeGenCXX/trivial-auto-var-init.cpp
    M clang/test/Sema/warn-alloca.c

  Log Message:
  -----------
  [clang][auto-init] Provide __builtin_alloca*_uninitialized variants

When `-ftrivial-auto-var-init=` is enabled, allocas unconditionally
receive auto-initialization since [1].

In certain cases, it turns out, this is causing problems. For example,
when using alloca to add a random stack offset, as the Linux kernel does
on syscall entry [2]. In this case, none of the alloca'd stack memory is
ever used, and initializing it should be controllable; furthermore, it
is not always possible to safely call memset (see [2]).

Introduce `__builtin_alloca_uninitialized()` (and
`__builtin_alloca_with_align_uninitialized`), which never performs
initialization when `-ftrivial-auto-var-init=` is enabled.

[1] https://reviews.llvm.org/D60548
[2] https://lkml.kernel.org/r/YbHTKUjEejZCLyhX@elver.google.com

Reviewed By: glider

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




More information about the All-commits mailing list