[all-commits] [llvm/llvm-project] 93b262: [clang][CodeGen] Emit lifetime markers for block-s...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Fri Sep 11 10:54:14 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93b2629d1d1f52e90549e6e12901c3f51ceba273
      https://github.com/llvm/llvm-project/commit/93b2629d1d1f52e90549e6e12901c3f51ceba273
  Author: Nick Desaulniers <ndesaulniers at google.com>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M clang/lib/CodeGen/CGExpr.cpp
    M clang/lib/Sema/JumpDiagnostics.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/AST/ast-dump-expr-json.c
    M clang/test/C/C11/n1285_1.c
    M clang/test/CodeGen/attr-counted-by-with-sanitizers.c
    M clang/test/CodeGen/attr-counted-by-without-sanitizers.c
    A clang/test/CodeGen/compound-literal-lifetime.c
    M clang/test/CodeGenObjC/arc-ternary-op.m
    M clang/test/Sema/scope-check.c

  Log Message:
  -----------
  [clang][CodeGen] Emit lifetime markers for block-scoped compound literals in C (#219045)

In C (C99/C11/C23 ยง6.2.4.5), block-scoped compound literals have
automatic storage duration extending to the end of the enclosing block
scope.  Previously, Clang emitted alloca storage without lifetime
markers (@llvm.lifetime.start / @llvm.lifetime.end), preventing LLVM's
StackColoring pass from merging stack slots across disjoint scopes and
inflating stack frame size.

Following John McCall's guidance in #68746:
1. In Sema, record block-scoped compound literals in ExprCleanupObjects
so
   the enclosing full-expression is wrapped in an ExprWithCleanups.
2. In CodeGen, emit @llvm.lifetime.start before evaluating initializers
and
   schedule CallLifetimeEnd as a cleanup.

Checking a build of an x86_64 Linux kernel defconfig build, this shaves
448 bytes off the stack usage for azx_probe(), one of the larger stack
users in the kernel.

Assisted-by: Gemini
Fixes: https://github.com/llvm/llvm-project/issues/68746



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list