[PATCH] D75755: [AArch64][Fix] LdSt optimization generate premature stack-popping
Diogo N. Sampaio via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 6 08:46:23 PST 2020
dnsampaio created this revision.
dnsampaio added reviewers: fhahn, foad, thegameg, eli.friedman.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.
When moving add and sub to memory operand instructions,
aarch64-ldst-opt would prematurally pop the stack pointer,
before memory instructions that do access the stack using
indirect loads.
e.g.
int foo(int offset){
int local[4] = {0};
return local[offset];
}
would generate:
sub sp, sp, #16 ; Push the stack
mov x8, sp ; Save stack in register
stp xzr, xzr, [sp], #16 ; Zero initialize stack, and post-increment, making it invalid
------ If an exception goes here, the stack value might be corrupted
ldr w0, [x8, w0, sxtw #2] ; Access correct position, but it is not guarded by SP
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75755
Files:
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
llvm/test/CodeGen/AArch64/arm64-nvcast.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75755.248744.patch
Type: text/x-patch
Size: 8948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200306/f48017ca/attachment.bin>
More information about the llvm-commits
mailing list