@@ -674,7 +674,10 @@ RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
674
674
if (hasBP (MF)) {
675
675
FrameReg = RISCVABI::getBPReg ();
676
676
// |--------------------------| -- <-- FP
677
- // | callee-saved registers | | <----.
677
+ // | callee-allocated save | | <----|
678
+ // | area for register varargs| | |
679
+ // |--------------------------| | |
680
+ // | callee-saved registers | | |
678
681
// |--------------------------| -- |
679
682
// | realignment (the size of | | |
680
683
// | this area is not counted | | |
@@ -699,7 +702,10 @@ RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
699
702
} else {
700
703
FrameReg = RISCV::X2;
701
704
// |--------------------------| -- <-- FP
702
- // | callee-saved registers | | <----.
705
+ // | callee-allocated save | | <----|
706
+ // | area for register varargs| | |
707
+ // |--------------------------| | |
708
+ // | callee-saved registers | | |
703
709
// |--------------------------| -- |
704
710
// | realignment (the size of | | |
705
711
// | this area is not counted | | |
@@ -742,6 +748,9 @@ RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
742
748
// the frame size.
743
749
//
744
750
// |--------------------------| -- <-- FP
751
+ // | callee-allocated save | |
752
+ // | area for register varargs| |
753
+ // |--------------------------| |
745
754
// | callee-saved registers | |
746
755
// |--------------------------| | MFI.getStackSize()
747
756
// | scalar local variables | |
@@ -756,7 +765,10 @@ RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
756
765
// When using SP to access frame objects, we need to add RVV stack size.
757
766
//
758
767
// |--------------------------| -- <-- FP
759
- // | callee-saved registers | | <----.
768
+ // | callee-allocated save | | <----|
769
+ // | area for register varargs| | |
770
+ // |--------------------------| | |
771
+ // | callee-saved registers | | |
760
772
// |--------------------------| -- |
761
773
// | Padding after RVV | | |
762
774
// | (not counted in | | |
@@ -786,8 +798,11 @@ RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
786
798
Offset += StackOffset::getFixed (MFI.getStackSize ());
787
799
}
788
800
} else if (MFI.getStackID (FI) == TargetStackID::ScalableVector) {
801
+ int ScalarLocalVarSize = MFI.getStackSize () -
802
+ RVFI->getCalleeSavedStackSize () -
803
+ RVFI->getVarArgsSaveSize ();
789
804
Offset += StackOffset::get (
790
- alignTo (MFI. getStackSize () - RVFI-> getCalleeSavedStackSize () , 8 ),
805
+ alignTo (ScalarLocalVarSize , 8 ),
791
806
RVFI->getRVVStackSize ());
792
807
}
793
808
}
0 commit comments