[PATCH] D157701: [SystemZ][z/OS] Fix the entry point marker for leaf functions
Neumann Hon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 11 03:34:18 PDT 2023
Everybody0523 created this revision.
Everybody0523 added reviewers: uweigand, Kai.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Everybody0523 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The function emitFunctionEntryLabel does not look at whether or not a function is a leaf when setting the entry flags, and instead blindly marks all functions as non-leaf routines.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157701
Files:
llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
Index: llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
===================================================================
--- llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
+++ llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
@@ -380,6 +380,10 @@
}
; CHECK-LABEL: leaf_func
+; CHECK: .long 8 * DSA Size 0x0
+; CHECK-NEXT: * Entry Flags
+; CHECK-NEXT: * Bit 1: 1 = Leaf function
+; CHECK-NEXT: * Bit 2: 0 = Does not use alloca
; CHECK-NOT: aghi 4,
; CHECK-NOT: stmg
; CHECK: agr 1, 2
Index: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -1315,14 +1315,16 @@
// EntryPoint Marker
const MachineFrameInfo &MFFrame = MF->getFrameInfo();
bool IsUsingAlloca = MFFrame.hasVarSizedObjects();
+ uint32_t DSASize = MFFrame.getStackSize();
+ bool IsLeaf = DSASize == 0 && MFFrame.getCalleeSavedInfo().empty();
// Set Flags
uint8_t Flags = 0;
+ if (IsLeaf)
+ Flags |= 0x08;
if (IsUsingAlloca)
Flags |= 0x04;
- uint32_t DSASize = MFFrame.getStackSize();
-
// Combine into top 27 bits of DSASize and bottom 5 bits of Flags.
uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0; // (x/32) << 5
DSAAndFlags |= Flags;
@@ -1340,6 +1342,10 @@
if (OutStreamer->isVerboseAsm()) {
OutStreamer->AddComment("DSA Size 0x" + Twine::utohexstr(DSASize));
OutStreamer->AddComment("Entry Flags");
+ if (Flags & 0x08)
+ OutStreamer->AddComment(" Bit 1: 1 = Leaf function");
+ else
+ OutStreamer->AddComment(" Bit 1: 0 = Non-leaf function");
if (Flags & 0x04)
OutStreamer->AddComment(" Bit 2: 1 = Uses alloca");
else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157701.549323.patch
Type: text/x-patch
Size: 1816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/169611e0/attachment.bin>
More information about the llvm-commits
mailing list