[all-commits] [llvm/llvm-project] 7aa2b0: [X86] Use unsigned comparison for stack clash prob...
Nick Desaulniers via All-commits
all-commits at lists.llvm.org
Thu Apr 16 09:16:15 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7aa2b040236bfa8b60ebec69af60f5a334ee160e
https://github.com/llvm/llvm-project/commit/7aa2b040236bfa8b60ebec69af60f5a334ee160e
Author: Nick Desaulniers <ndesaulniers at google.com>
Date: 2026-04-16 (Thu, 16 Apr 2026)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
M llvm/test/CodeGen/X86/stack-clash-small-alloc-medium-align.ll
Log Message:
-----------
[X86] Use unsigned comparison for stack clash probing loop (#192355)
The stack clash probing loop generated in `EmitLoweredProbedAlloca` used
a signed comparison (`X86::COND_GE`) to determine when the allocation
target had been reached.
In 32-bit mode, memory addresses above `0x80000000` have the sign bit
set. If the stack pointer lands in this region, treating the addresses
as signed integers causes the comparison logic to fail. This leads to
incorrect loop execution, resulting in an infinite loop and a crash
(segmentation fault) when setting up custom stacks for pthreads mapped
above `0x80000000` in a 32b process.
This patch changes the condition code to `X86::COND_AE` (Above or
Equal), which generates an unsigned comparison. This ensures that
addresses are treated correctly as unsigned quantities on all targets.
On 64-bit systems, this change has no practical effect on valid
user-space addresses because they do not use the sign bit (being
restricted to the lower half of the address space). However, using
unsigned comparison is the correct behavior for pointer arithmetic and
bounds checks.
Reported-by: Wonsik Kim <wonsik at google.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list