Index: llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp +++ llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp @@ -49,6 +49,11 @@ : 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. RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS); for (unsigned I = 0, E = array_lengthof(SpillOffsetTable); I != E; ++I) @@ -57,6 +62,11 @@ const TargetFrameLowering::SpillSlot * SystemZFrameLowering::getCalleeSavedSpillSlots(unsigned &NumEntries) const { + // The offsets in SpillOffsetTable are relative to incoming stack pointer + // and are therefore incorrect here since we have defined the Local Area + // Offset as -SystemZMC::CallFrameSize. This however does not matter since + // the created frame object offsets are not used as we build the STMG/LMG + // instructions. NumEntries = array_lengthof(SpillOffsetTable); return SpillOffsetTable; }