diff options
author | 3405691582 <dsk@google.com> | 2025-03-31 12:17:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-31 09:17:55 -0700 |
commit | c180e249d0013474d502cd779ec65b33cf7e9468 (patch) | |
tree | 61c91b1f37f2e3bd61dcc75346476e25efa200e8 /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | 87602f6d03ada10d0de7f1440320ffec4eb86790 (diff) | |
download | llvm-c180e249d0013474d502cd779ec65b33cf7e9468.zip llvm-c180e249d0013474d502cd779ec65b33cf7e9468.tar.gz llvm-c180e249d0013474d502cd779ec65b33cf7e9468.tar.bz2 |
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.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 3da66a4..91ae904 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -2005,6 +2005,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"); } |