@@ -1270,7 +1270,7 @@ void SystemZAsmPrinter::emitFunctionBodyEnd() {
12701270
12711271static void emitPPA1Flags (std::unique_ptr<MCStreamer> &OutStreamer, bool VarArg,
12721272 bool StackProtector, bool FPRMask, bool VRMask,
1273- bool EHBlock, bool HasName) {
1273+ bool EHBlock, bool HasArgAreaLength, bool HasName) {
12741274 enum class PPA1Flag1 : uint8_t {
12751275 DSA64Bit = (0x80 >> 0 ),
12761276 VarArg = (0x80 >> 7 ),
@@ -1282,8 +1282,9 @@ static void emitPPA1Flags(std::unique_ptr<MCStreamer> &OutStreamer, bool VarArg,
12821282 LLVM_MARK_AS_BITMASK_ENUM (ExternalProcedure)
12831283 };
12841284 enum class PPA1Flag3 : uint8_t {
1285+ HasArgAreaLength = (0x80 >> 1 ),
12851286 FPRMask = (0x80 >> 2 ),
1286- LLVM_MARK_AS_BITMASK_ENUM (FPRMask )
1287+ LLVM_MARK_AS_BITMASK_ENUM (HasArgAreaLength )
12871288 };
12881289 enum class PPA1Flag4 : uint8_t {
12891290 EPMOffsetPresent = (0x80 >> 0 ),
@@ -1307,6 +1308,9 @@ static void emitPPA1Flags(std::unique_ptr<MCStreamer> &OutStreamer, bool VarArg,
13071308 if (StackProtector)
13081309 Flags2 |= PPA1Flag2::STACKPROTECTOR;
13091310
1311+ if (HasArgAreaLength)
1312+ Flags3 |= PPA1Flag3::HasArgAreaLength; // Add emit ArgAreaLength flag.
1313+
13101314 // SavedGPRMask, SavedFPRMask, and SavedVRMask are precomputed in.
13111315 if (FPRMask)
13121316 Flags3 |= PPA1Flag3::FPRMask; // Add emit FPR mask flag.
@@ -1339,6 +1343,9 @@ static void emitPPA1Flags(std::unique_ptr<MCStreamer> &OutStreamer, bool VarArg,
13391343 OutStreamer->emitInt8 (static_cast <uint8_t >(Flags2)); // Flags 2.
13401344
13411345 OutStreamer->AddComment (" PPA1 Flags 3" );
1346+ if ((Flags3 & PPA1Flag3::HasArgAreaLength) == PPA1Flag3::HasArgAreaLength)
1347+ OutStreamer->AddComment (
1348+ " Bit 1: 1 = Argument Area Length is in optional area" );
13421349 if ((Flags3 & PPA1Flag3::FPRMask) == PPA1Flag3::FPRMask)
13431350 OutStreamer->AddComment (" Bit 2: 1 = FP Reg Mask is in optional area" );
13441351 OutStreamer->emitInt8 (
@@ -1477,19 +1484,38 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
14771484
14781485 bool NeedEmitEHBlock = !MF->getLandingPads ().empty ();
14791486
1487+ // Optional Argument Area Length.
1488+ // Note: This represents the length of the argument area that we reserve
1489+ // in our stack for setting up arguments for calls to other
1490+ // routines. If this optional field is not set, LE will reserve
1491+ // 128 bytes for the argument area. This optional field is
1492+ // created if greater than 128 bytes is required - to guarantee
1493+ // the required space is reserved on stack extension in the new
1494+ // extension. This optional field is also created if the
1495+ // routine has alloca(). This may reduce stack space
1496+ // if alloca() call causes a stack extension.
1497+ bool HasArgAreaLength =
1498+ (AllocaReg != 0 ) || (MFFrame.getMaxCallFrameSize () > 128 );
1499+
14801500 bool HasName =
14811501 MF->getFunction ().hasName () && MF->getFunction ().getName ().size () > 0 ;
14821502
14831503 emitPPA1Flags (OutStreamer, MF->getFunction ().isVarArg (),
14841504 MFFrame.hasStackProtectorIndex (), SavedFPRMask != 0 ,
1485- TargetHasVector && SavedVRMask != 0 , NeedEmitEHBlock, HasName);
1505+ TargetHasVector && SavedVRMask != 0 , NeedEmitEHBlock,
1506+ HasArgAreaLength, HasName);
14861507
14871508 OutStreamer->AddComment (" Length/4 of Parms" );
14881509 OutStreamer->emitInt16 (
14891510 static_cast <uint16_t >(ZFI->getSizeOfFnParams () / 4 )); // Parms/4.
14901511 OutStreamer->AddComment (" Length of Code" );
14911512 OutStreamer->emitAbsoluteSymbolDiff (FnEndSym, CurrentFnEPMarkerSym, 4 );
14921513
1514+ if (HasArgAreaLength) {
1515+ OutStreamer->AddComment (" Argument Area Length" );
1516+ OutStreamer->emitInt32 (MFFrame.getMaxCallFrameSize ());
1517+ }
1518+
14931519 // Emit saved FPR mask and offset to FPR save area (0x20 of flags 3).
14941520 if (SavedFPRMask) {
14951521 OutStreamer->AddComment (" FPR mask" );
0 commit comments