[PATCH] D88541: [AArch64] Don't merge sp decrement into later stores when using WinCFI
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 01:41:09 PDT 2020
mstorsjo created this revision.
mstorsjo added reviewers: efriedma, dnsampaio, rnk, ssijaric, TomTan.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.
mstorsjo requested review of this revision.
This matches the corresponding existing case in AArch64LoadStoreOpt::findMatchingUpdateInsnForward. (The fixme comment is a copy of that one, from D75755 <https://reviews.llvm.org/D75755>.)
Both cases could also be modified to check MBBI->getFlag(FrameSetup/FrameDestroy) instead of forbidding any optimization involving SP, but the effect is probably pretty much the same.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88541
Files:
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
Index: llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
+++ llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
@@ -26,7 +26,10 @@
entry:
; FIXME: Missed optimization, the entire SP push/pop could be removed
; CHECK-LABEL: f2
-; CHECK: stp xzr, xzr, [sp, #-16]!
+; CHECK: sub sp, sp, #16
+; CHECK-NEXT: .seh_stackalloc 16
+; CHECK-NEXT: .seh_endprologue
+; CHECK-NEXT: stp xzr, xzr, [sp]
; CHECK-NEXT: mov x0, xzr
; CHECK-NEXT: mov x1, xzr
; CHECK-NEXT: .seh_startepilogue
Index: llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -1857,6 +1857,17 @@
}
}
+ const bool BaseRegSP = BaseReg == AArch64::SP;
+ if (BaseRegSP) {
+ // FIXME: For now, we always block the optimization over SP in windows
+ // targets as it requires to adjust the unwind/debug info, messing up
+ // the unwind info can actually cause a miscompile.
+ const MCAsmInfo *MAI = I->getMF()->getTarget().getMCAsmInfo();
+ if (MAI->usesWindowsCFI() &&
+ I->getMF()->getFunction().needsUnwindTableEntry())
+ return E;
+ }
+
// Track which register units have been modified and used between the first
// insn (inclusive) and the second insn.
ModifiedRegUnits.clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88541.295200.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200930/cbb6a3a6/attachment.bin>
More information about the llvm-commits
mailing list