[LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb...
authorWesley Wiser <wwiser@gmail.com>
Tue, 23 Jul 2024 16:43:30 +0000 (11:43 -0500)
committerTobias Hieta <tobias@hieta.se>
Fri, 26 Jul 2024 07:21:02 +0000 (09:21 +0200)
commitc5f34876cd00c01bf5ecd38a2bfc5377867e4b04
tree5585a67225b4b4e3c73d755935fee37bc21cf3da
parent3120547296c558634261ec944d7846be56eba306
[LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263)

Rebase of #84114. I've only included the core changes to frame layout
calculation & CFI generation which sidesteps the regressions found after
merging #84114. Since these changes are a necessary precursor to the
overall fix and are themselves slightly beneficial as CFI is now
generated correctly, I think it is reasonable to merge this first step.

---

For very large stack frames, the offset from the stack pointer to a
local can be more than 2^31 which overflows various `int` offsets in the
frame lowering code.

This patch updates the frame lowering code to calculate the offsets as
64-bit values and fixes CFI to use the corrected sizes.

After this patch, additional work is needed to fix offset truncations in
each target's codegen.

(cherry picked from commit ca076f7a63f6a80e2e38315ec462be354b196b8d)
19 files changed:
llvm/include/llvm/CodeGen/MachineFrameInfo.h
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/include/llvm/MC/MCAsmBackend.h
llvm/include/llvm/MC/MCDwarf.h
llvm/lib/CodeGen/CFIInstrInserter.cpp
llvm/lib/CodeGen/MachineFrameInfo.cpp
llvm/lib/CodeGen/PrologEpilogInserter.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/PowerPC/huge-frame-size.ll
llvm/test/CodeGen/RISCV/pr88365.ll
llvm/test/CodeGen/X86/huge-stack.ll