[all-commits] [llvm/llvm-project] 0a652c: [codegen] Add StackFrameLayoutAnalysisPass

Paul Kirth via All-commits all-commits at lists.llvm.org
Fri Jan 13 12:53:04 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0a652c540556a118bbd9386ed3ab7fd9e60a9754
      https://github.com/llvm/llvm-project/commit/0a652c540556a118bbd9386ed3ab7fd9e60a9754
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2023-01-13 (Fri, 13 Jan 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    A clang/test/Frontend/stack-layout-remark.c
    M llvm/include/llvm/CodeGen/Passes.h
    M llvm/include/llvm/InitializePasses.h
    M llvm/lib/CodeGen/CMakeLists.txt
    M llvm/lib/CodeGen/CodeGen.cpp
    A llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
    M llvm/lib/CodeGen/TargetPassConfig.cpp
    M llvm/test/CodeGen/AArch64/O0-pipeline.ll
    M llvm/test/CodeGen/AArch64/O3-pipeline.ll
    M llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
    M llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
    M llvm/test/CodeGen/ARM/O3-pipeline.ll
    A llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll
    M llvm/test/CodeGen/Generic/llc-start-stop.ll
    M llvm/test/CodeGen/PowerPC/O0-pipeline.ll
    M llvm/test/CodeGen/PowerPC/O3-pipeline.ll
    M llvm/test/CodeGen/RISCV/O0-pipeline.ll
    M llvm/test/CodeGen/RISCV/O3-pipeline.ll
    M llvm/test/CodeGen/X86/O0-pipeline.ll
    M llvm/test/CodeGen/X86/opt-pipeline.ll
    A llvm/test/CodeGen/X86/stack-frame-layout-remarks.ll

  Log Message:
  -----------
  [codegen] Add StackFrameLayoutAnalysisPass

Issue #58168 describes the difficulty diagnosing stack size issues
identified by -Wframe-larger-than. For simple code, its easy to
understand the stack layout and where space is being allocated, but in
more complex programs, where code may be heavily inlined, unrolled, and
have duplicated code paths, it is no longer easy to manually inspect the
source program and understand where stack space can be attributed.

This patch implements a machine function pass that emits remarks with a
textual representation of stack slots, and also outputs any available
debug information to map source variables to those slots.

The new behavior can be used by adding `-Rpass-analysis=stack-frame-layout`
to the compiler invocation. Like other remarks the diagnostic
information can be saved to a file in a machine readable format by
adding -fsave-optimzation-record.

Fixes: #58168

Reviewed By: nickdesaulniers, thegameg

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




More information about the All-commits mailing list