Skip to content

Commit 23d1ec6

Browse files
authored
[AArch64][MIR] Serialize AArch64MachineFunctionInfo::HasStackFrame to MIR (#158122)
This patch adds serialization of AArch64MachineFunctionInfo::HasStackFrame into MIR.
1 parent 607a813 commit 23d1ec6

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ yaml::AArch64FunctionInfo::AArch64FunctionInfo(
2828
: HasRedZone(MFI.hasRedZone()),
2929
StackSizeSVE(MFI.hasCalculatedStackSizeSVE()
3030
? std::optional<uint64_t>(MFI.getStackSizeSVE())
31-
: std::nullopt) {}
31+
: std::nullopt),
32+
HasStackFrame(MFI.hasStackFrame()
33+
? std::optional<bool>(MFI.hasStackFrame())
34+
: std::nullopt) {}
3235

3336
void yaml::AArch64FunctionInfo::mappingImpl(yaml::IO &YamlIO) {
3437
MappingTraits<AArch64FunctionInfo>::mapping(YamlIO, *this);
@@ -40,6 +43,8 @@ void AArch64FunctionInfo::initializeBaseYamlFields(
4043
HasRedZone = YamlMFI.HasRedZone;
4144
if (YamlMFI.StackSizeSVE)
4245
setStackSizeSVE(*YamlMFI.StackSizeSVE);
46+
if (YamlMFI.HasStackFrame)
47+
setHasStackFrame(*YamlMFI.HasStackFrame);
4348
}
4449

4550
static std::pair<bool, bool> GetSignReturnAddress(const Function &F) {

llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ namespace yaml {
600600
struct AArch64FunctionInfo final : public yaml::MachineFunctionInfo {
601601
std::optional<bool> HasRedZone;
602602
std::optional<uint64_t> StackSizeSVE;
603+
std::optional<bool> HasStackFrame;
603604

604605
AArch64FunctionInfo() = default;
605606
AArch64FunctionInfo(const llvm::AArch64FunctionInfo &MFI);
@@ -612,6 +613,7 @@ template <> struct MappingTraits<AArch64FunctionInfo> {
612613
static void mapping(IO &YamlIO, AArch64FunctionInfo &MFI) {
613614
YamlIO.mapOptional("hasRedZone", MFI.HasRedZone);
614615
YamlIO.mapOptional("stackSizeSVE", MFI.StackSizeSVE);
616+
YamlIO.mapOptional("hasStackFrame", MFI.HasStackFrame);
615617
}
616618
};
617619

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# RUN: llc -run-pass=prologepilog -mtriple arm64-apple-ios -o - -simplify-mir \
2+
# RUN: -verify-machineinstrs %s | FileCheck %s
3+
4+
# CHECK: hasStackFrame: true
5+
6+
--- |
7+
8+
define i32 @f(i32 %a, i32 %b) #0 {
9+
%local_array = alloca [10 x i32], align 4
10+
%temp = alloca i32, align 4
11+
store i32 %a, ptr %temp, align 4
12+
%loaded = load i32, ptr %temp, align 4
13+
%gep = getelementptr inbounds [10 x i32], ptr %local_array, i64 0, i64 5
14+
store i32 %loaded, ptr %gep, align 4
15+
%result = add i32 %loaded, %b
16+
%blah = call i32 @foo(i32 noundef %result)
17+
ret i32 %blah
18+
}
19+
20+
declare i32 @foo(i32 noundef)
21+
22+
...
23+
---
24+
name: f
25+
frameInfo:
26+
adjustsStack: true
27+
stack:
28+
- { id: 0, name: local_array, size: 40, alignment: 4, local-offset: -40 }
29+
- { id: 1, name: temp, size: 4, alignment: 4, local-offset: -44 }
30+
body: |
31+
bb.0:
32+
liveins: $w0, $w1
33+
34+
STRWui renamable $w0, %stack.1.temp, 0
35+
STRWui renamable $w0, %stack.0.local_array, 5
36+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
37+
$w0 = ADDWrr killed renamable $w0, killed renamable $w1
38+
BL @foo, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
39+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
40+
RET_ReallyLR implicit $w0
41+
...

0 commit comments

Comments
 (0)