[PATCH] D135101: [AArch64] Add missing SEH_Nop when aligning the stack
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 01:00:44 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f7fbf837625: [AArch64] Add missing SEH_Nop when aligning the stack (authored by mstorsjo).
Changed prior to commit:
https://reviews.llvm.org/D135101?vs=464797&id=465311#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135101/new/
https://reviews.llvm.org/D135101
Files:
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/wineh-align-stack.ll
Index: llvm/test/CodeGen/AArch64/wineh-align-stack.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/wineh-align-stack.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s
+
+define dso_local void @func() {
+entry:
+ %buf = alloca [64 x i8], align 32
+ %arraydecay = getelementptr inbounds [64 x i8], ptr %buf, i64 0, i64 0
+ call void @other(ptr noundef %arraydecay)
+ ret void
+}
+
+declare dso_local void @other(ptr noundef)
+
+; CHECK-LABEL: func:
+; CHECK-NEXT: .seh_proc func
+; CHECK-NEXT: // %bb.0:
+; CHECK-NEXT: stp x29, x30, [sp, #-16]!
+; CHECK-NEXT: .seh_save_fplr_x 16
+; CHECK-NEXT: mov x29, sp
+; CHECK-NEXT: .seh_set_fp
+; CHECK-NEXT: sub x9, sp, #80
+; CHECK-NEXT: .seh_nop
+; CHECK-NEXT: and sp, x9, #0xffffffffffffffe0
+; CHECK-NEXT: .seh_stackalloc 80
+; CHECK-NEXT: .seh_endprologue
+
+; FIXME: Ideally, the SEH prologue wouldn't include the stack realigning
+; instructions at all, but it's enough to end the prologue after .seh_set_fp.
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -4334,8 +4334,6 @@
int Imm = (int)(ThisVal << LocalShiftSize);
if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
(SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
- if (HasWinCFI)
- *HasWinCFI = true;
if (Imm == 0)
BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_SetFP)).setMIFlag(Flag);
else
@@ -4345,12 +4343,13 @@
assert(Offset == 0 && "Expected remaining offset to be zero to "
"emit a single SEH directive");
} else if (DestReg == AArch64::SP) {
- if (HasWinCFI)
- *HasWinCFI = true;
assert(SrcReg == AArch64::SP && "Unexpected SrcReg for SEH_StackAlloc");
BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_StackAlloc))
.addImm(Imm)
.setMIFlag(Flag);
+ } else {
+ BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_Nop))
+ .setMIFlag(Flag);
}
if (HasWinCFI)
*HasWinCFI = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135101.465311.patch
Type: text/x-patch
Size: 2275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/8014f732/attachment.bin>
More information about the llvm-commits
mailing list