[all-commits] [llvm/llvm-project] f162be: [RISCV] Use unsigned comparison for stack clash pr...
Nick Desaulniers via All-commits
all-commits at lists.llvm.org
Thu Apr 16 12:35:11 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f162be248636046a20e71209e139347e084b637a
https://github.com/llvm/llvm-project/commit/f162be248636046a20e71209e139347e084b637a
Author: Nick Desaulniers <ndesaulniers at google.com>
Date: 2026-04-16 (Thu, 16 Apr 2026)
Changed paths:
M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
M llvm/test/CodeGen/RISCV/rvv/stack-probing-dynamic.ll
M llvm/test/CodeGen/RISCV/stack-clash-prologue.ll
Log Message:
-----------
[RISCV] Use unsigned comparison for stack clash probing loop (#192485)
The stack clash probing loop generated in `emitDynamicProbedAlloc` used
a signed comparison (`RISCV::COND_BLT`) 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 patch changes the condition code to `RISCV::COND_BLTU` (Branch if
Less Than Unsigned), 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.
Link: #192355
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