[libunwind] 987ee20 - [LFI][libunwind] Enable x86_64_lfi for compiler-rt and skip reserved registers in libunwind (#232552)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 21 19:53:58 PDT 2026
Author: Zachary Yedidia
Date: 2026-10-21T19:53:53-07:00
New Revision: 987ee202905055120a44348af86ca878c4f55722
URL: https://github.com/llvm/llvm-project/commit/987ee202905055120a44348af86ca878c4f55722
DIFF: https://github.com/llvm/llvm-project/commit/987ee202905055120a44348af86ca878c4f55722.diff
LOG: [LFI][libunwind] Enable x86_64_lfi for compiler-rt and skip reserved registers in libunwind (#232552)
This enables `x86_64_lfi` as a CMake target in compiler-rt and skips
LFI's reserved registers for libunwind's save/restore sequence.
Added:
Modified:
compiler-rt/cmake/builtin-config-ix.cmake
compiler-rt/lib/builtins/CMakeLists.txt
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
Removed:
################################################################################
diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index 082ade13c595af..a9b38620cbee86 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -83,7 +83,7 @@ set(ARM32 arm armhf armv4t armv5te armv6 armv6m armv7m armv7em armv7 armv7s armv
set(AVR avr)
set(HEXAGON hexagon)
set(X86 i386)
-set(X86_64 x86_64)
+set(X86_64 x86_64 x86_64_lfi)
set(LOONGARCH64 loongarch64)
set(MIPS32 mips mipsel)
set(MIPS64 mips64 mips64el)
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 838a9b8665630b..ab9c707b3db44d 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -438,6 +438,9 @@ if (NOT MSVC)
# Darwin x86_64 Haswell
set(x86_64h_SOURCES ${x86_64_SOURCES})
+ # x86_64 LFI
+ set(x86_64_lfi_SOURCES ${x86_64_SOURCES})
+
if (WIN32)
set(x86_64_SOURCES
${x86_64_SOURCES}
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index b299bcd0a75949..6c9dcc48c309ad 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -113,8 +113,11 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto)
movq 88(%rdi), %r11
movq 96(%rdi), %r12
movq 104(%rdi), %r13
+# Skip reloading r14/r15 under LFI; reserved by LFI ABI.
+#if !defined(__LFI__)
movq 112(%rdi), %r14
movq 120(%rdi), %r15
+#endif
# skip rflags
# skip cs
# skip fs
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index c51b5b8d176646..81d32009952895 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -145,8 +145,11 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
movq %r11, 88(PTR)
movq %r12, 96(PTR)
movq %r13,104(PTR)
+# Skip spilling r14/r15 under LFI; reserved by LFI ABI.
+#if !defined(__LFI__)
movq %r14,112(PTR)
movq %r15,120(PTR)
+#endif
movq (%rsp),TMP
movq TMP,128(PTR) # store return address as rip
# skip rflags
More information about the cfe-commits
mailing list