@@ -993,32 +993,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
993
993
++MBBI;
994
994
}
995
995
996
- // The code below is not applicable to funclets. We have emitted all the SEH
997
- // opcodes that we needed to emit. The FP and BP belong to the containing
998
- // function.
999
- if (IsFunclet) {
1000
- if (NeedsWinCFI) {
1001
- HasWinCFI = true ;
1002
- BuildMI (MBB, MBBI, DL, TII->get (AArch64::SEH_PrologEnd))
1003
- .setMIFlag (MachineInstr::FrameSetup);
1004
- }
1005
-
1006
- // SEH funclets are passed the frame pointer in X1. If the parent
1007
- // function uses the base register, then the base register is used
1008
- // directly, and is not retrieved from X1.
1009
- if (F.hasPersonalityFn ()) {
1010
- EHPersonality Per = classifyEHPersonality (F.getPersonalityFn ());
1011
- if (isAsynchronousEHPersonality (Per)) {
1012
- BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::COPY), AArch64::FP)
1013
- .addReg (AArch64::X1).setMIFlag (MachineInstr::FrameSetup);
1014
- MBB.addLiveIn (AArch64::X1);
1015
- }
1016
- }
1017
-
1018
- return ;
1019
- }
1020
-
1021
- if (HasFP) {
996
+ // For funclets the FP belongs to the containing function.
997
+ if (!IsFunclet && HasFP) {
1022
998
// Only set up FP if we actually need to.
1023
999
int64_t FPOffset = isTargetDarwin (MF) ? (AFI->getCalleeSavedStackSize () - 16 ) : 0 ;
1024
1000
@@ -1161,7 +1137,9 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1161
1137
1162
1138
// Allocate space for the rest of the frame.
1163
1139
if (NumBytes) {
1164
- const bool NeedsRealignment = RegInfo->needsStackRealignment (MF);
1140
+ // Alignment is required for the parent frame, not the funclet
1141
+ const bool NeedsRealignment =
1142
+ !IsFunclet && RegInfo->needsStackRealignment (MF);
1165
1143
unsigned scratchSPReg = AArch64::SP;
1166
1144
1167
1145
if (NeedsRealignment) {
@@ -1215,7 +1193,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1215
1193
// FIXME: Clarify FrameSetup flags here.
1216
1194
// Note: Use emitFrameOffset() like above for FP if the FrameSetup flag is
1217
1195
// needed.
1218
- if (RegInfo->hasBasePointer (MF)) {
1196
+ // For funclets the BP belongs to the containing function.
1197
+ if (!IsFunclet && RegInfo->hasBasePointer (MF)) {
1219
1198
TII->copyPhysReg (MBB, MBBI, DL, RegInfo->getBaseRegister (), AArch64::SP,
1220
1199
false );
1221
1200
if (NeedsWinCFI) {
@@ -1232,6 +1211,19 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1232
1211
.setMIFlag (MachineInstr::FrameSetup);
1233
1212
}
1234
1213
1214
+ // SEH funclets are passed the frame pointer in X1. If the parent
1215
+ // function uses the base register, then the base register is used
1216
+ // directly, and is not retrieved from X1.
1217
+ if (IsFunclet && F.hasPersonalityFn ()) {
1218
+ EHPersonality Per = classifyEHPersonality (F.getPersonalityFn ());
1219
+ if (isAsynchronousEHPersonality (Per)) {
1220
+ BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::COPY), AArch64::FP)
1221
+ .addReg (AArch64::X1)
1222
+ .setMIFlag (MachineInstr::FrameSetup);
1223
+ MBB.addLiveIn (AArch64::X1);
1224
+ }
1225
+ }
1226
+
1235
1227
if (needsFrameMoves) {
1236
1228
const DataLayout &TD = MF.getDataLayout ();
1237
1229
const int StackGrowth = isTargetDarwin (MF)
0 commit comments