From a7d3f6933ddbbd1c0b20529a0734ed66f98d75a0 Mon Sep 17 00:00:00 2001 From: Jonas Paulsson Date: Mon, 25 Nov 2019 18:48:47 +0100 Subject: [SystemZ] Return the right offsets from getCalleeSavedSpillSlots(). // Due to the SystemZ ABI, the DWARF CFA (Canonical Frame Address) is not // equal to the incoming stack pointer, but to incoming stack pointer plus // 160. The getOffsetOfLocalArea() returned value is interpreted as "the // offset of the local area from the CFA". The immediate offsets into the Register save area returned by getCalleeSavedSpillSlots() should take this offset into account, which this patch makes sure of. Patch and review by Ulrich Weigand. https://reviews.llvm.org/D70427 --- llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp | 49 ++++++++++++++---------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp') diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp index d183eb5b3eb..24b99e49fc6 100644 --- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp @@ -21,27 +21,27 @@ using namespace llvm; namespace { -// The ABI-defined register save slots, relative to the incoming stack -// pointer. +// The ABI-defined register save slots, relative to the CFA (i.e. +// incoming stack pointer + SystemZMC::CallFrameSize). static const TargetFrameLowering::SpillSlot SpillOffsetTable[] = { - { SystemZ::R2D, 0x10 }, - { SystemZ::R3D, 0x18 }, - { SystemZ::R4D, 0x20 }, - { SystemZ::R5D, 0x28 }, - { SystemZ::R6D, 0x30 }, - { SystemZ::R7D, 0x38 }, - { SystemZ::R8D, 0x40 }, - { SystemZ::R9D, 0x48 }, - { SystemZ::R10D, 0x50 }, - { SystemZ::R11D, 0x58 }, - { SystemZ::R12D, 0x60 }, - { SystemZ::R13D, 0x68 }, - { SystemZ::R14D, 0x70 }, - { SystemZ::R15D, 0x78 }, - { SystemZ::F0D, 0x80 }, - { SystemZ::F2D, 0x88 }, - { SystemZ::F4D, 0x90 }, - { SystemZ::F6D, 0x98 } + { SystemZ::R2D, -SystemZMC::CallFrameSize + 0x10 }, + { SystemZ::R3D, -SystemZMC::CallFrameSize + 0x18 }, + { SystemZ::R4D, -SystemZMC::CallFrameSize + 0x20 }, + { SystemZ::R5D, -SystemZMC::CallFrameSize + 0x28 }, + { SystemZ::R6D, -SystemZMC::CallFrameSize + 0x30 }, + { SystemZ::R7D, -SystemZMC::CallFrameSize + 0x38 }, + { SystemZ::R8D, -SystemZMC::CallFrameSize + 0x40 }, + { SystemZ::R9D, -SystemZMC::CallFrameSize + 0x48 }, + { SystemZ::R10D, -SystemZMC::CallFrameSize + 0x50 }, + { SystemZ::R11D, -SystemZMC::CallFrameSize + 0x58 }, + { SystemZ::R12D, -SystemZMC::CallFrameSize + 0x60 }, + { SystemZ::R13D, -SystemZMC::CallFrameSize + 0x68 }, + { SystemZ::R14D, -SystemZMC::CallFrameSize + 0x70 }, + { SystemZ::R15D, -SystemZMC::CallFrameSize + 0x78 }, + { SystemZ::F0D, -SystemZMC::CallFrameSize + 0x80 }, + { SystemZ::F2D, -SystemZMC::CallFrameSize + 0x88 }, + { SystemZ::F4D, -SystemZMC::CallFrameSize + 0x90 }, + { SystemZ::F6D, -SystemZMC::CallFrameSize + 0x98 } }; } // end anonymous namespace @@ -49,10 +49,17 @@ SystemZFrameLowering::SystemZFrameLowering() : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, Align(8), -SystemZMC::CallFrameSize, Align(8), false /* StackRealignable */) { + // Due to the SystemZ ABI, the DWARF CFA (Canonical Frame Address) is not + // equal to the incoming stack pointer, but to incoming stack pointer plus + // 160. The getOffsetOfLocalArea() returned value is interpreted as "the + // offset of the local area from the CFA". + // Create a mapping from register number to save slot offset. + // These offsets are relative to the start of the register save area. RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS); for (unsigned I = 0, E = array_lengthof(SpillOffsetTable); I != E; ++I) - RegSpillOffsets[SpillOffsetTable[I].Reg] = SpillOffsetTable[I].Offset; + RegSpillOffsets[SpillOffsetTable[I].Reg] = + SystemZMC::CallFrameSize + SpillOffsetTable[I].Offset; } const TargetFrameLowering::SpillSlot * -- cgit v1.2.3