[PATCH] D137599: [libunwind][PowerPC] Fix saving/restoring VSX registers on LE systems

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 16:16:52 PST 2022


nemanjai created this revision.
nemanjai added reviewers: libunwind, xingxue, PowerPC.
nemanjai added a project: libunwind.
Herald added subscribers: libcxx-commits, shchenz, krytarowski.
Herald added 1 blocking reviewer(s): libunwind.
Herald added a project: All.
nemanjai requested review of this revision.
Herald added a project: LLVM.

Currently, libunwind just uses `stxvd2x/lxvd2x` to save/restore VSX registers respectively. This puts the registers in doubleword-reversed order into memory on little endian systems. If both the save and restore are done the same way, this isn't a problem. However if the unwinder is just restoring a callee-saved register, it will restore it in the wrong order (since function prologues save them in the correct order).

This patch fixes the order by:

- Adding a check for ISA 3.0 if the GLIBC used at build time supports such a check
- On machines that support ISA 3.0, it uses non-swapping DQ-Form instructions (`stxv/lxv`)
- On machines that don't support ISA 3.0 (or on builds with GLIBC that is too old) swaps are added after the loads and before the stores


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137599

Files:
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/UnwindRegistersSave.S
  libunwind/src/assembly.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137599.473822.patch
Type: text/x-patch
Size: 11180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221108/a52e2f92/attachment.bin>


More information about the llvm-commits mailing list