@@ -1029,32 +1029,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1029
1029
++MBBI;
1030
1030
}
1031
1031
1032
- // The code below is not applicable to funclets. We have emitted all the SEH
1033
- // opcodes that we needed to emit. The FP and BP belong to the containing
1034
- // function.
1035
- if (IsFunclet) {
1036
- if (NeedsWinCFI) {
1037
- HasWinCFI = true ;
1038
- BuildMI (MBB, MBBI, DL, TII->get (AArch64::SEH_PrologEnd))
1039
- .setMIFlag (MachineInstr::FrameSetup);
1040
- }
1041
-
1042
- // SEH funclets are passed the frame pointer in X1. If the parent
1043
- // function uses the base register, then the base register is used
1044
- // directly, and is not retrieved from X1.
1045
- if (F.hasPersonalityFn ()) {
1046
- EHPersonality Per = classifyEHPersonality (F.getPersonalityFn ());
1047
- if (isAsynchronousEHPersonality (Per)) {
1048
- BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::COPY), AArch64::FP)
1049
- .addReg (AArch64::X1).setMIFlag (MachineInstr::FrameSetup);
1050
- MBB.addLiveIn (AArch64::X1);
1051
- }
1052
- }
1053
-
1054
- return ;
1055
- }
1056
-
1057
- if (HasFP) {
1032
+ // For funclets the FP belongs to the containing function.
1033
+ if (!IsFunclet && HasFP) {
1058
1034
// Only set up FP if we actually need to.
1059
1035
int64_t FPOffset = isTargetDarwin (MF) ? (AFI->getCalleeSavedStackSize () - 16 ) : 0 ;
1060
1036
@@ -1197,7 +1173,9 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1197
1173
1198
1174
// Allocate space for the rest of the frame.
1199
1175
if (NumBytes) {
1200
- const bool NeedsRealignment = RegInfo->needsStackRealignment (MF);
1176
+ // Alignment is required for the parent frame, not the funclet
1177
+ const bool NeedsRealignment =
1178
+ !IsFunclet && RegInfo->needsStackRealignment (MF);
1201
1179
unsigned scratchSPReg = AArch64::SP;
1202
1180
1203
1181
if (NeedsRealignment) {
@@ -1250,7 +1228,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1250
1228
// FIXME: Clarify FrameSetup flags here.
1251
1229
// Note: Use emitFrameOffset() like above for FP if the FrameSetup flag is
1252
1230
// needed.
1253
- if (RegInfo->hasBasePointer (MF)) {
1231
+ // For funclets the BP belongs to the containing function.
1232
+ if (!IsFunclet && RegInfo->hasBasePointer (MF)) {
1254
1233
TII->copyPhysReg (MBB, MBBI, DL, RegInfo->getBaseRegister (), AArch64::SP,
1255
1234
false );
1256
1235
if (NeedsWinCFI) {
@@ -1267,6 +1246,19 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1267
1246
.setMIFlag (MachineInstr::FrameSetup);
1268
1247
}
1269
1248
1249
+ // SEH funclets are passed the frame pointer in X1. If the parent
1250
+ // function uses the base register, then the base register is used
1251
+ // directly, and is not retrieved from X1.
1252
+ if (IsFunclet && F.hasPersonalityFn ()) {
1253
+ EHPersonality Per = classifyEHPersonality (F.getPersonalityFn ());
1254
+ if (isAsynchronousEHPersonality (Per)) {
1255
+ BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::COPY), AArch64::FP)
1256
+ .addReg (AArch64::X1)
1257
+ .setMIFlag (MachineInstr::FrameSetup);
1258
+ MBB.addLiveIn (AArch64::X1);
1259
+ }
1260
+ }
1261
+
1270
1262
if (needsFrameMoves) {
1271
1263
const DataLayout &TD = MF.getDataLayout ();
1272
1264
const int StackGrowth = isTargetDarwin (MF)
0 commit comments