[all-commits] [llvm/llvm-project] a58ad3: [clang] Add size filter for stack auto init (#74777)

Haopeng Liu via All-commits all-commits at lists.llvm.org
Thu Jan 18 11:10:28 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a58ad3e2a33eafc821714f9d27b74279fb4d607c
      https://github.com/llvm/llvm-project/commit/a58ad3e2a33eafc821714f9d27b74279fb4d607c
  Author: Haopeng Liu <153236845+haopliu at users.noreply.github.com>
  Date:   2024-01-18 (Thu, 18 Jan 2024)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Basic/LangOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/CGDecl.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    A clang/test/CodeGenCXX/auto-var-init-max-size.cpp
    M clang/test/Driver/clang_f_opts.c

  Log Message:
  -----------
  [clang] Add size filter for stack auto init (#74777)

Add a clang flag, "-ftrivial-auto-var-init-max-size=" so that clang
skips auto-init a variable if the auto-init memset size exceeds the flag
setting (in bytes). Note that this skipping doesn't apply to
runtime-sized variables like VLA.

Considerations: "__attribute__((uninitialized))" can be used to manually
opt variables out. However, there are thousands of large variables
(e.g., >=1KB, most of them are arrays and used as buffers) in big
codebase. Manually opting them out one by one is not efficient.




More information about the All-commits mailing list