Skip to content

Commit 607ac48

Browse files
committed
[M68k] Fix CC value offsets always assuming 32-bit slot sizes
When using a calling convention that doesn't promote i8/i16 to i32, the stack offset would still be shifted under the assumption that the value is in a 32-bit slot. This instead calculates stack offset based on the actual slot size.
1 parent a1209d8 commit 607ac48

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

llvm/lib/Target/M68k/M68kISelLowering.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,12 @@ M68kTargetLowering::LowerMemArgument(SDValue Chain, CallingConv::ID CallConv,
446446
else
447447
ValVT = VA.getValVT();
448448

449-
// Because we are dealing with BE architecture we need to offset loading of
450-
// partial types
449+
// Since it's BE architecture, if the type size is smaller than the slot size
450+
// (e.g. i8 stored in a 4-byte slot) then move offset to the end of the slot.
451451
int Offset = VA.getLocMemOffset();
452-
if (VA.getValVT() == MVT::i8) {
453-
Offset += 3;
454-
} else if (VA.getValVT() == MVT::i16) {
455-
Offset += 2;
456-
}
452+
int LocSize = VA.getLocVT().getFixedSizeInBits();
453+
int ValSize = VA.getValVT().getFixedSizeInBits();
454+
Offset += (LocSize - ValSize) / 8;
457455

458456
// TODO Interrupt handlers
459457
// Calculate SP offset of interrupt parameter, re-arrange the slot normally

0 commit comments

Comments
 (0)