[PATCH] D84152: [PowerPC] Fix wrong codegen when stack pointer has to realign
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 05:27:30 PDT 2020
lkail created this revision.
lkail added reviewers: PowerPC, jsji, steven.zhang.
Herald added subscribers: llvm-commits, shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
Current powerpc backend generates wrong code sequence if stack pointer has to realign if `-fstack-clash-protection` enabled. There are two situations
1. Current `PREPARE_PROBED_ALLOCA` takes `NegSizeReg` as input and returns
`FinalStackPtr`. `FinalStackPtr=StackPtr+ActualNegSize` is calculated correctly, however code following `PREPARE_PROBED_ALLOCA` still uses value of `NegSizeReg`, which does not contain `ActualNegSize` if `MaxAlign > TargetAlign`, to calculate loop trip count and residual number of bytes.
2. When `HasBP && MaxAlign > 1`, the backend should generate a subtraction instruction rather than a `stux` instruction.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=46759
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84152
Files:
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
llvm/test/CodeGen/PowerPC/pr46759.ll
llvm/test/CodeGen/PowerPC/stack-clash-dynamic-alloca.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84152.279186.patch
Type: text/x-patch
Size: 24998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200720/13c7414e/attachment-0001.bin>
More information about the llvm-commits
mailing list