[all-commits] [llvm/llvm-project] 01a796: [CodeGen] Replace CCState's getNextStackOffset wit...

Sergei Barannikov via All-commits all-commits at lists.llvm.org
Wed May 17 11:52:15 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 01a796744745d8413d0821c734caf2fbe19f2eca
      https://github.com/llvm/llvm-project/commit/01a796744745d8413d0821c734caf2fbe19f2eca
  Author: Sergei Barannikov <barannikov88 at gmail.com>
  Date:   2023-05-17 (Wed, 17 May 2023)

  Changed paths:
    M llvm/include/llvm/CodeGen/CallingConvLower.h
    M llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
    M llvm/lib/CodeGen/CallingConvLower.cpp
    M llvm/lib/Target/AArch64/AArch64FastISel.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
    M llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    M llvm/lib/Target/ARC/ARCISelLowering.cpp
    M llvm/lib/Target/ARM/ARMCallLowering.cpp
    M llvm/lib/Target/ARM/ARMCallingConv.cpp
    M llvm/lib/Target/ARM/ARMFastISel.cpp
    M llvm/lib/Target/ARM/ARMISelLowering.cpp
    M llvm/lib/Target/AVR/AVRISelLowering.cpp
    M llvm/lib/Target/BPF/BPFISelLowering.cpp
    M llvm/lib/Target/CSKY/CSKYISelLowering.cpp
    M llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
    M llvm/lib/Target/Lanai/LanaiISelLowering.cpp
    M llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
    M llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
    M llvm/lib/Target/M68k/M68kISelLowering.cpp
    M llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
    M llvm/lib/Target/Mips/MipsCallLowering.cpp
    M llvm/lib/Target/Mips/MipsFastISel.cpp
    M llvm/lib/Target/Mips/MipsISelLowering.cpp
    M llvm/lib/Target/PowerPC/PPCFastISel.cpp
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/lib/Target/Sparc/SparcISelLowering.cpp
    M llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
    M llvm/lib/Target/VE/VEISelLowering.cpp
    M llvm/lib/Target/X86/X86CallLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/lib/Target/XCore/XCoreISelLowering.cpp

  Log Message:
  -----------
  [CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)

The term "next stack offset" is misleading because the next argument is
not necessarily allocated at this offset due to alignment constrains.
It also does not make much sense when allocating arguments at negative
offsets (introduced in a follow-up patch), because the returned offset
would be past the end of the next argument.

Reviewed By: arsenm

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


  Commit: da42b2846c82063bd1bce78d6a046f78f218eb72
      https://github.com/llvm/llvm-project/commit/da42b2846c82063bd1bce78d6a046f78f218eb72
  Author: Sergei Barannikov <barannikov88 at gmail.com>
  Date:   2023-05-17 (Wed, 17 May 2023)

  Changed paths:
    M llvm/include/llvm/CodeGen/CallingConvLower.h
    M llvm/lib/CodeGen/CallingConvLower.cpp
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    M llvm/lib/Target/Sparc/SparcISelLowering.cpp
    A llvm/unittests/CodeGen/CCStateTest.cpp
    M llvm/unittests/CodeGen/CMakeLists.txt
    M llvm/utils/TableGen/CallingConvEmitter.cpp

  Log Message:
  -----------
  [CodeGen] Support allocating of arguments by decreasing offsets

Previously, `CCState::AllocateStack` always allocated stack space by increasing
offsets. For targets with stack growing up (away from zero) it is more
convenient to allocate arguments by decreasing offsets, so that the first
argument is at the top of the stack. This is important when calling a function
with variable number of arguments: the callee does not know the size of the
stack, but must be able to access "fixed" arguments. For that to work, the
"fixed" arguments should have fixed offsets relative to the stack top, i.e. the
variadic arguments area should be at the stack bottom (at lowest addresses).

The in-tree target with stack growing up is AMDGPU, but it allocates
arguments by increasing addresses. It does not support variadic arguments.

A drive-by change is to promote stack size/offset to 64-bit integer.
This is what MachineFrameInfo expects.

Reviewed By: arsenm

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


Compare: https://github.com/llvm/llvm-project/compare/dc3069dadf6f...da42b2846c82


More information about the All-commits mailing list