[llvm-branch-commits] [llvm] be4097b - Fix crash lowering stack guard on OpenBSD/aarch64. (#125416)
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 9 13:11:39 PDT 2025
Author: 3405691582
Date: 2025-05-09T13:11:20-07:00
New Revision: be4097b6ee5793c33f6731e9cf908e67d627fded
URL: https://github.com/llvm/llvm-project/commit/be4097b6ee5793c33f6731e9cf908e67d627fded
DIFF: https://github.com/llvm/llvm-project/commit/be4097b6ee5793c33f6731e9cf908e67d627fded.diff
LOG: Fix crash lowering stack guard on OpenBSD/aarch64. (#125416)
TargetLoweringBase::getIRStackGuard refers to a platform-specific guard
variable. Before this change, TargetLoweringBase::getSDagStackGuard only
referred to a different variable.
This means that SelectionDAGBuilder's getLoadStackGuard does not get
memory operands. However, AArch64InstrInfo::expandPostRAPseudo assumes
that the passed MachineInstr has nonzero memoperands, causing a
segfault.
We have two possible options here: either disabling the LOAD_STACK_GUARD
node entirely in AArch64TargetLowering::useLoadStackGuardNode or just
making the platform-specific values match across TargetLoweringBase.
Here, we try the latter.
(cherry picked from commit c180e249d0013474d502cd779ec65b33cf7e9468)
Added:
Modified:
llvm/lib/CodeGen/TargetLoweringBase.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 9c56912aa6ba0..411f59e714b0e 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1987,6 +1987,9 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
// Currently only support "standard" __stack_chk_guard.
// TODO: add LOAD_STACK_GUARD support.
Value *TargetLoweringBase::getSDagStackGuard(const Module &M) const {
+ if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
+ return M.getNamedValue("__guard_local");
+ }
return M.getNamedValue("__stack_chk_guard");
}
More information about the llvm-branch-commits
mailing list